Answer the question
In order to leave comments, you need to log in
How to inform the user that he has successfully made changes?
I am using UpdateView to change the data. And when the changes are done, I want a message to be displayed on the main screen using messages.success(request, "message")
How can this be implemented in a class?
class ChangeComent(UpdateView):
model = Coments
template_name = "myshop/change_coment.html"
fields = ("text",)
success_url = reverse_lazy("index")
pk_url_kwarg = "pk_coment"
def get_form(self, *args, **kwargs):
form = super(ChangeComent, self).get_form(*args, **kwargs)
form.fields['text'].widget.attrs["class"] = "form-control"
form.fields['text'].widget.attrs["rows"] = 5
return form
def get_context_data(self, **kwargs):
context = super(ChangeComent, self).get_context_data(**kwargs)
context['categories'] = Category.objects.all()
return context
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question