Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hope you are familiar with <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="nofollow">HTTP methods</a> like GET and POST.</p> <p><code>request</code> object represents a single request by any user agent. So it can be a request that's sent from browser from you when you browse a particular page or from a crawler from a search engine. Read more about request <a href="https://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects" rel="nofollow">here</a></p> <p><code>request.POST</code> is an attribute of this <code>request</code> object, it's a <a href="https://docs.djangoproject.com/en/dev/ref/request-response/#querydict-objects" rel="nofollow">QueryDict</a> (much similar to a normal Python dict). It contains the HTTP POST parameters that are sent to your view.</p> <p>In short in your example:</p> <pre><code>def create(request): if request.POST: # check if the request is POST request and it contains any parameter form = ArticleForm(request.POST) # then pass all those parameters to the form if form.is_valid: # process the form to check if it's valid form.save() # save the data if it's valid else: form = ArticleForm() # if not valid data, initialize an new / empty form args = {} # create a dict to pass to the template args.update(csrf(request)) # add the CSRF token args['form'] = form # add the 'form' above to the 'args' dict return render_to_response('create_article.html', args) # pass that dict to template </code></pre> <p>Not so sure why you have this example, normally I would do the last part like this:</p> <pre><code>def create(request): .... your code .... else: form = ArticleForm() return render(request, 'create_article.html', { form: form }) </code></pre> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload