Search code examples
djangoherokudjango-flatpages

why my django flatpages cannot show in heroku


I followed https://docs.djangoproject.com/en/dev/ref/contrib/flatpages/ and
I created a flatpage using my own template in http://localhost:8000/about-me/ and it works fine.
But when i've pushed it into heroku and reproduced to create one page, the server returns Internal Server Error

the Server log :

Traceback (most recent call last):

File "/app/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 283, in run self.result = application(self.environ, self.start_response)

File "/app/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in call response = self.get_response(request)

File "/app/lib/python2.7/site-packages/django/core/handlers/base.py", line 153, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info())

File "/app/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception return callback(request, **param_dict)

File "/app/lib/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs)

File "/app/lib/python2.7/site-packages/django/views/defaults.py", line 30, in server_error t = loader.get_template(template_name) # You need to create a 500.html template.

File "/app/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template template, origin = find_template(template_name)

File "/app/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template raise TemplateDoesNotExist(name)

TemplateDoesNotExist: 500.html


Solution

  • The stack trace tells me that it can't find your 500.html template. Maybe if you give it one ti will clear up the error message to what the actual problem is.

    Is the domain correct for the Site ID used by your flatpage? For instance if locally you say you site is the "localhost", but in heroku if it's served by "dev.internalnet.example" domain, that could cause issues.

    Also, try setting DEBUG=True in settings.py, hit the page and you should get a fancy page with the exact stack trace causing the issue (and then it won't need to look for a 500.html template, although you should have one).