Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Forms Model Forms Save a Model Form

When saving the Django form, how can I best use the return HttpResponseRequest statement?

The statement is return HttpResponseRedirect('product:create'). Is there a better way to resolve this issue?

2 Answers

Lewis Cowles
Lewis Cowles
74,902 Points

I think you are missing a reverse call so

    return HttpResponseRedirect(reverse('products:create'))

Also not that it makes a difference, but I also used double quotes, as it matched the instructions (it should not matter)

Try checking all import statements. My main problem is that HTTP is title-cased to Http in HttpResponseRedirect

Hi Lewis,

I'm glad you decided to provide a more complete answer in this other forum post/thread:

https://teamtreehouse.com/community/answer-saving-a-model-form