Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Forms Model Forms Edit an Instance

The 'Updated' or 'Quiz Added' message doesnt show up when I edit or save a new quiz.

The 'Updated' or 'Quiz Added' message doesn't show up when I edit or save a new quiz.

Tim Ding
Tim Ding
11,768 Points

Hi Manyung,

I am having the same exact issue. I am seeing the messages cookie being added to my browser, but no text is displayed on the page. To me, this suggests that maybe the middleware is not displaying the cookie content. This is just my guess, and I'm not well-versed in Django architecture.

I have searched the internet quite a bit, but have not been able to find any solution to this problem. One thing I tried (you may have tried it too) was this - https://stackoverflow.com/questions/32600473/django-messages-not-showing-after-httpresponseredirect But it didn't work for me. In fact I don't see the messages cookie appear in the session storage when this setting is enabled.

My settings seem to be okay too. I have got the 'django.contrib.sessions.middleware.SessionMiddleware', and 'django.contrib.messages.middleware.MessageMiddleware' defined in MIDDLEWARE, as well as 'django.contrib.messages.context_processors.messages' in the 'context_processors' list. The ONLY difference between my copy of settings.py and the downloadable version on Treehouse is that I had to comment out #'django.contrib.auth.middleware.SessionAuthenticationMiddleware'. According to the Django doc, this class has been removed in Django 2.0. https://docs.djangoproject.com/en/2.0/releases/2.0/#miscellaneous Not sure if this has anything to do with this particular issue.

Please let me know if you have found what the problem is.

Thanks, Tim

1 Answer

Bronson Avila
Bronson Avila
4,160 Points

I know it's an old question, and the OP may no longer be in need of an answer, but I'd first want to know if OP is coding in the course workspace or if they are coding everything locally on their own machine from scratch. If you are just coding locally, it might be possible that your template is just missing the block that is required for displaying messages, e.g.:

  {% if messages %}
    <ul>
      {% for message in messages %}
        <li class="callout {{ message.tags }}">{{ message }}</li>
      {% endfor %}
    </ul>
  {% endif %}

Something like that should be in your detail view (or a parent layout.html from which the detail view is extended). This block is included in the course workspace, but Kenneth does not mention it during this video.