python - Django form processing -


i'm during form tutorial on https://docs.djangoproject.com/en/1.8/topics/forms/. i'm trying make simple form element, posting data. function launched in urls.py:

def get_name(request): # if post request need process form data if request.method == 'post':     # create form instance , populate data request:     form = nameform(request.post)     # check whether it's valid:     if form.is_valid():         # process data in form.cleaned_data required         # ...         # redirect new url:         return httpresponseredirect('/thanks/')  # if (or other method) we'll create blank form else:     form = nameform()  return render(request, 'name.html', {'form': form}) 

html code looks follows:

<form action="/your-name/" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="submit" /> </form> 

when input data form , click 'submit' button, function connected /your-name/ url launched , i'm redirected /your-name/. i'm wondering why function connected /thanks/ url not launching. how can reached?

for view work, form's action /your-name/ must served view get_name.

you haven't shown url patterns, it's impossible tell whether mistake there or not.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -