Q:

How to show an alert on the success url

I want to display a message that form has been successfully submitted when the user gets redirected to success url but I cannot find a solution to do it. Please help.Thanks!
views
class FeedbackCreate(CreateView):
    model = Feedback
    form_class = FeedbackForm
    template_name = 'feedback_form.html'
    success_url = '/qworky/dash/'

    def form_valid(self, form):
        self.object = form.save(commit=False)
        self.object.premises =    Premises.objects.get(userprofile__user=self.request.user)
         self.object.client = UserProfile.objects.get(user=self.request.user)
         return super(FeedbackCreate, self).form_valid(form)

A:

You can make use of the SuccessMessageMixin mixin [Django-doc]:
from django.contrib.messages.views import SuccessMessageMixin

class FeedbackCreate(SuccessMessageMixin, CreateView):
    model = Feedback
    form_class = FeedbackForm
    template_name = 'feedback_form.html'
    success_url = '/qworky/dash/'
    success_message = 'Well done! We saved your feedback!'

    def form_valid(self, form):
        self.object = form.save(commit=False)
        self.object.premises =    Premises.objects.get(userprofile__user=self.request.user)
        self.object.client = UserProfile.objects.get(user=self.request.user)
        return super(FeedbackCreate, self).form_valid(form)
In your templates you can render such messages, as is discussed in the documentation on the messages framework. It might be better to do the rendering on your base template, such that on all pages, the messages can be delivered.

