-1

私は非常に奇妙な状況に陥っています。Django の DEBUG は True ですが、特定のスクリプトを実行すると、Django の標準のデバッグ出力ではなく、次のエラーが返されます。

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, ababab@gmail.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at ababab.com Port 80

なぜこれが起こっているのでしょうか?以下のコードを削除すると、エラーが発生しないことに気付きました。ビューは次のとおりです。

import datetime
from datetime import datetime, date, timedelta

def index():
    mostViewed = ProfileVisits.objects.filter(timestamp__gt = datetime.now() - timedelta(7))[0]
    return HttpResponse(mostViewed)

mostViewed = len(mostViewed)一番下の行の直前に行を挿入すると、1期待される出力が得られることに気付きました。また、 mostViewedを繰り返し処理してリストに追加しても、エラーがないことに気付きました。

私を正しい方向に向けてくれるものは何でも大歓迎です。

4

1 に答える 1