Skip to content

Using django messages

Gjergj Kadriu edited this page Jul 29, 2018 · 3 revisions

Using django-messages

  • Include django_messages to the INSTALLED_APPS setting
  • Include django_messages.urls to your main urls.py

Templates

  • Create a folder message inside your apps templates folder
  • Create create_message.html inside message folder
  • Create a form with form.as_p and submit button that posts to the same page
  • Create message_confirm_delete.html inside message folder
  • Create a form (method POST) with a submit button that posts to the same path
You can change default template directory by changing inheriting CreateMessage/DeleteMessage and change template_name variable.

Template tags

You can use request.user|getInbox on your html pages to get all conversations the current user is participating along with last_message ( dict of {conversation:last_message} )

Example:

    {% for conv,message in request.user|getInbox %}
  • {{conv}} - {{message}}
  • {% endfor %}

Clone this wiki locally