5👍
✅
Include the data as GET
parameters in your success url.
def get_success_url(self):
url = reverse('success')
# maybe use urlencode for more complicated parameters
return "%s?foo=%s" % (url, self.request.POST['bar'])
Then in your template, access the parameters in the GET data.
foo: {{ request.GET.foo }}
2👍
I was trying to figure this out too and a simple solution is to use:
from django.contrib import messages
In get_success_url(self) you can write
def get_success_url(self)
messages.add_message(self.request, messages.SUCCESS, 'Contact Successfully Updated!')
return reverse('contacts:contact_detail', args=(self.get_object().id,))
And in your template you can access this message via
{% for message in messages %}
{{ message }}
{% endfor %}
- [Django]-Inverted logic in Django ModelForm
- [Django]-Django adds %2f in place of the / in the template for an image field
- [Django]-Django account_activation_token.check_token always return False in constant_time_compare()
1👍
One way to accomplish what you’re looking to do would be through the use of Sessions. Store whatever values you need on the user’s session object, and access them from within the SuccessView. Check out the Django session documentation for more details.
- [Django]-How to use uwsgi restart django
- [Django]-Django signals not fired when saving from admin interface
Source:stackexchange.com