I have a form that and after the user fills in this form, I want to redirect to a URL that looks something like this
r'^user/(?P<id>\d+)/$'
The <id>
is the primary key in the database...how do I go about this coz I'm stuck at this point
I have a form that and after the user fills in this form, I want to redirect to a URL that looks something like this
r'^user/(?P<id>\d+)/$'
The <id>
is the primary key in the database...how do I go about this coz I'm stuck at this point
Ok, so in your .html file, you should have an action= in your form, which sort of looks like that regular expression. At the very least it should look something similar to:
object.id would be replaced with whatever object you passed to the html file in your view.
The url template tag allows you to save some repetition here. It also prevents you from breaking the form if you change urls.py. If your urlpattern looks like this:
Then you could use the template tag like this: