From f2298a661cab0a8b4e4462eb9b2efd70b4de9905 Mon Sep 17 00:00:00 2001 From: Innocent Zenda Date: Mon, 6 Nov 2023 16:34:18 +0300 Subject: [PATCH] load contacts when contact is created or updated closes #23 --- pim/contacts/models.py | 3 +++ .../templates/contacts/contact_form.html | 13 ++++++------- pim/contacts/templates/contacts/index.html | 4 +++- pim/contacts/views.py | 18 ++++++++++++++++-- static/js/django-debug-toolbar.js | 18 +++++++++--------- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/pim/contacts/models.py b/pim/contacts/models.py index 805a316..d2ca6e9 100644 --- a/pim/contacts/models.py +++ b/pim/contacts/models.py @@ -33,6 +33,9 @@ class Contact(models.Model): created_at = models.DateTimeField(auto_now_add=True) modified_at = models.DateTimeField(auto_now=True) + class Meta: + ordering = ('name',) + def __str__(self): return self.name diff --git a/pim/contacts/templates/contacts/contact_form.html b/pim/contacts/templates/contacts/contact_form.html index d4bcd44..be23827 100644 --- a/pim/contacts/templates/contacts/contact_form.html +++ b/pim/contacts/templates/contacts/contact_form.html @@ -1,18 +1,17 @@ {% load crispy_forms_tags %} {% load i18n %} -

- {% blocktrans %} - {{ title }} Contact - {% endblocktrans %} -

- {% if object %}
{% else %} - + {% endif %} +

+ {% blocktrans %} + {{ title }} Contact + {% endblocktrans %} +

{% csrf_token %} {{ form | crispy }}