Thursday, November 28, 2013

Re: GET and POST in forms. Please help me understand the logic!

Have a look at the book RESTful Web Services, page 5 (Chapter 1) and on.

http://it-ebooks.info/book/391/

 

You can read it on-line http://it-ebooks.info/read/391/ -- physical page 26/440,

section "HTTP: Documents in Envelopes".

 

Have a nice day,

   P.

______________________________________________________________
> Od: Andrew Taylor <andydtaylor@gmail.com>
> Komu: <django-users@googlegroups.com>
> Datum: 28.11.2013 04:24
> Předmět: GET and POST in forms. Please help me understand the logic!
>

Hi,
I'm struggling with the concepts of get and post and where these status come from in the workflow. I have worked my way through the official pages on forms but I have not quite understood this to my satisfaction.
I get the gist that:
  • get is for requesting data and 
  • the query string parameters are visible 
  • Running multiple get operations with say a bookmarked link has no negative effect
whereas with post
  • post is for making database changes
Beyond this I am a little clueless.
  • When does a request method get assigned? 
  • In other words, with this code below, what would have made the request method become post (or get)? Is this related to a preceding view?
  • Does a request object have to have a get or a post dictionary in it? Could it have neither?
  • Does a request object going to a form have to have a get or a post dictionary in it?
  • Is it the case that with "add_category.html" the page could open with neither a get or post in the request, and while the "add_category" view is running the request method POST could be assigned?
  • Does a POST method invoke form validation?
Example:
def add_category(request, category_name_url=""):
    context = RequestContext(request)
    if request.method == 'POST':
        form = CategoryForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return index(request)
        else:
            print form.errors
    else:
        form = CategoryForm
    return render_to_response('rango/add_category.html', {'form': form}, context)
Thanks,
Andy

 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6367ae1d-fc71-4137-9140-3573a8a5dedc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20131128131427.977944EC%40atlas.cz.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment