django – what goes into the form action parameter when view requires a parameter?

If you want to explicitly set the action, assuming you have a variable username in your template,

<form name="form" method="post" action="{% url myview.views username %}">

or you could assign a name for the url in your urls.py so you could reference it like this:

# urls.py
urlpatterns += patterns('myview.views',
    url(r'^(?P<user>\w+)/', 'myview', name="myurl"), # I can't think of a better name
)

# template.html
<form name="form" method="post" action="{% url myurl username %}">

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)