I have a CreateView and an UpdateView with success messages in both. But, only the UpdateView success message works and the CreateView message isn't show. Why is this happening?
from django.contrib.messages.views import SuccessMessageMixin
class CreateRedirect (CreateView):
model = MarketingRedirect
template_name = 'marketing_redirect/create_redirect.html'
success_url = reverse_lazy('backend_redirect')
fields = ['redirect_from', 'redirect_to']
success_message = "Redirect successfully created!"
class EditRedirect(SuccessMessageMixin, UpdateView):
model = MarketingRedirect
fields = ['redirect_from', 'redirect_to']
template_name = 'marketing_redirect/edit_redirect.html'
context_object_name = 'redirect'
success_url = reverse_lazy('backend_redirect')
success_message = 'Review successfully updated'
Inherit SuccessMessageMixin for class CreateRedirect as shown below:
class CreateRedirect(SuccessMessageMixin, CreateView):
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With