Thank you Ramadan Kareem
On Friday, April 24, 2020 at 12:11:09 AM UTC-4, mohamed khaled wrote:
-- On Friday, April 24, 2020 at 12:11:09 AM UTC-4, mohamed khaled wrote:
just use SuccessMessageMixinfrom django.contrib.messages.views import SuccessMessageMixin class PostCreateView(LoginRequiredMixin, SuccessMessageMixin , CreateView):model = Postfields = ['caption', 'design']template_name = "post_form.html"success_url = '/score'success_message = "Your Design has been submitted for Review"
it will work
On Friday, 24 April 2020 03:24:56 UTC+2, Ahmed Khairy wrote:I have created this class with the success message but I am not receiving the success message I requested, other pages are showing them but this one is notWhat might be wrong?In the views:class PostCreateView(LoginRequiredMixin , CreateView):model = Postfields = ['caption', 'design ']template_name = "post_form.html "success_url = '/score'success_message = "YourDesign has been submitted for "Review def form_valid(self, form): form.instance.author =self.request.user return super().form_valid (form)in the HTML<!-- Navbar -->{% if messages %}{% for message inmessages %}<div class="alert alert- {{ message.tags }}"style ="padding-top:80px">{{ message}} </div>{% endfor %}{% endif %}Thank you
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3be300cd-16b1-4b2b-8d52-1f4cd95f5015%40googlegroups.com.
No comments:
Post a Comment