I’m trying to redirect a user to a newly created object’s object.get_absolute_url() after saving a form. I’m not using a generic view, so I can’t use the post_save_redirect argument. The relevant portion of the view is like so:
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('story_detail', args=(story.user, story.id)))
Now how would I get at the story object between the form.save() and the HttpResponseRedirect so that I can do the reverse lookup?
A
ModelForm‘s save method returns the newly created model instance. In your case, this means you should be able to work with the following: