diff --git a/nummi/main/templates/main/base.html b/nummi/main/templates/main/base.html index 98da0b8..61de121 100644 --- a/nummi/main/templates/main/base.html +++ b/nummi/main/templates/main/base.html @@ -88,6 +88,11 @@ {% endspaceless %} {% endblock %}
+ {% if messages %} + + {% endif %} {% block body %}{% endblock %}
diff --git a/nummi/main/views.py b/nummi/main/views.py index 8095486..51a7131 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -1,8 +1,10 @@ from account.models import Account from category.models import Category +from django.contrib import messages from django.contrib.auth import views as auth_views from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse_lazy +from django.utils.html import format_html from django.views.generic import ( CreateView, DeleteView, @@ -55,7 +57,18 @@ class NummiCreateView(UserMixin, CreateView): return super().form_valid(form) def get_success_url(self): - return self.next or super().get_success_url() + surl = super().get_success_url() + messages.success( + self.request, + format_html( + "{name} {msg}", + surl=surl, + name=self.object, + msg="was created successfully", + ), + ) + + return self.next or surl class NummiUpdateView(UserMixin, UpdateView):