freedomofpress / pressfreedomtracker.us

Code for the U.S. Press Freedom Tracker project website
https://pressfreedomtracker.us
GNU Affero General Public License v3.0
17 stars 7 forks source link

[Exception] django.template.exceptions.TemplateDoesNotExist #669

Closed conorsch closed 6 years ago

conorsch commented 6 years ago

Accessing this URL generates a 500: https://pressfreedomtracker.us/organizations/ Full traceback:

{u'message': u'common/organization_page.html', u'traceback': [{u'line': 215, u'method': u'_get_response', u'file': u'/home/gcorn/pressfreedom-alpha/lib/python3.4/site-packages/django/core/handlers/base.py'}, {u'line': 107, u'method': u'render', u'file': u'/home/gcorn/pressfreedom-alpha/lib/python3.4/site-packages/django/template/response.py'}, {u'line': 82, u'method': u'rendered_content', u'file': u'/home/gcorn/pressfreedom-alpha/lib/python3.4/site-packages/django/template/response.py'}, {u'line': 66, u'method': u'resolve_template', u'file': u'/home/gcorn/pressfreedom-alpha/lib/python3.4/site-packages/django/template/response.py'}, {u'line': 25, u'method': u'get_template', u'file': u'/home/gcorn/pressfreedom-alpha/lib/python3.4/site-packages/django/template/loader.py'}], u'type': u'django.template.exceptions.TemplateDoesNotExist'}

In fact, several URLs with /organizations/ in it will generate an error:

However the following throws a 404, which is expected:

Looks like the URLs are PK-based, e.g. https://pressfreedomtracker.us/blog/?organization=66 is CPJ. The longer form URLs don't appear anywhere obvious on the current site, so the problem may be a sign of legacy code that should be cleaned up.

harrislapiroff commented 6 years ago

It looks like @conorsch is right that the problem here is that neither OrganizationIndexPage nor OrganizationPage is actually used as a page. Presumably when we first developed them we though they would be pages and you'd visit https://pressfreedomtracker.us/organizations/reporters-without-borders/ to get more information about it, but that never materialized as a feature.

Possible solutions:

  1. Change those models not to be Page subclasses so they don't have URLs at all. (Maybe make them snippets instead.)
  2. Update those models' serve methods to always raise a 404.
  3. Update those models' serve methods to redirect to the blog page with the organization filter on.

1 seems the cleanest from a database architecture perspective, but I think I actually prefer 2 or 3, because they wouldn't require a complex data migration and they leave open the possibility that organizations might still have detail pages on the site sometime in the future (for example with a description of the organization).