python - Django returns a strange Internal Server Error even though DEBUG=True -
i have strange situation guys. django's debug equal true, when run specific script returns below error, opposed django's standard debug output:
internal server error server encountered internal error or misconfiguration , unable complete request. please contact server administrator, ababab@gmail.com , inform them of time error occurred, , might have done may have caused error. more information error may available in server error log. apache/2.2.14 (ubuntu) server @ ababab.com port 80
why happening? noticed when remove below code, no errors. view is:
import datetime datetime import datetime, date, timedelta def index(): mostviewed = profilevisits.objects.filter(timestamp__gt = datetime.now() - timedelta(7))[0] return httpresponse(mostviewed)
i noticed when insert row mostviewed = len(mostviewed)
right before bottom row, output of 1
expected. noticed there no errors when iterate through mostviewed , add list.
anything point me in right direction appreciated.
you shouldn't wrapping query set in httpresponse. take @ django view docs, there lots of usage examples: https://docs.djangoproject.com/en/1.5/topics/http/views/
Comments
Post a Comment