I'm currently learning django from the 'How to tango with django' site and i'm unable to understand the chapter dealing with forms. Appreciate it if someone would help me out.
the first step is to create a forms page which maps to models.py. I seem to understand this part. I also understand that we create a view to process the data acquired from these forms. I'm not able to understand the below code in the views page.
from rango.forms import CategoryForm
def add_category(request):
# A HTTP POST?
if request.method == 'POST':
form = CategoryForm(request.POST)
else:
# If the request was not a POST, display the form to enter details.
form = CategoryForm()
-
How do the urlmapper know that a request method is POST or GET before the user actually enters any data in the form? On a similar note, when would a form have a get method?
-
form = CategoryForm(request.POST)- would someone explain this to me? CategoryForm looks to be a class which is already inheriting from another class what does the request.POST argument convey ?
Aucun commentaire:
Enregistrer un commentaire