djangozinnia

Django and zinnia: NoReverseMatch for all views after upgrading


I had zinnia (0.14.1) working fine with my django (1.6.6) app. I then upgraded my django to 1.8.0 and my zinnia to 0.15.1 and made several of the required changes, including changing the name of the template tags from zinnia_tags to zinnia in my custom templates.

I ran into a problem with 'zinnia' is not a registered namespace but resolved that by making the following change in my project's main urls.py:

# url(r'^blog/', include('zinnia.urls')),
url(r'^blog/', include('zinnia.urls', namespace='zinnia')),

But now I'm getting NoReverseMatch errors for all my pages. For example:

NoReverseMatch: Reverse for 'zinnia_entry_archive_day' with arguments '(u'2015', u'02', u'23')' and keyword arguments '{}' not found. 0 pattern(s) tried: []

and

NoReverseMatch: Reverse for 'zinnia_tag_detail' with arguments '(u'Alumni',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

I can't figure out what's going on. Could it be another setting I have to update?


Solution

  • Turns out that because I had adapted and customized the zinnia templates, and the namespace had changed, I also had to change the syntax wherever a url call was made. The underscores become colons.

    Convert

    <a href="{% url 'zinnia_tag_detail' tag %}" rel="tag">
    

    and

    <a href="{% url 'zinnia_entry_archive_year' date|date:"Y" %}" rel="archives">{{ date|date:"Y" }}</a>
    

    to

    <a href="{% url 'zinnia:tag_detail' tag %}" rel="tag">
    

    and

    <a href="{% url 'zinnia:entry_archive_year' date|date:"Y" %}" rel="archives">{{ date|date:"Y" }}</a>