Django - Get data from a form that is not a django.form
<p>I am working with Django in order to do a quite simple web application. </p>

<p>I am currently trying to have a succession of forms so that the user completes the information bits by bits. 
I first tried to do it only in HTML because I wanted to really have the hand on the presentation. Here is my code. </p>

<p>I have two templates, create_site.html and create_cpe.html. I need to get informations from the first page in order to know what to ask in the second page.</p>

<p>Here is my create_site.html</p>

<pre><code>&lt;body&gt;

&lt;form action="{% url 'confWeb:cpe_creation' %}" method="post" class="form-creation"&gt;
    {% csrf_token %}
    &lt;div class = "form-group row"&gt;
        &lt;label for="site_name" class="col-xs-3 col-form-label"&gt;Name of theSite&lt;/label&gt;
        &lt;div class="col-xs-9"&gt;
            &lt;input id="site_name" class="form-control" placeholder="Name" required="" autofocus="" type="text"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;CrÃ©er&lt;/button&gt;
&lt;/form&gt;
&lt;/body&gt;
</code></pre>

<p>And here is the views.py that I'm using to do all of this : </p>

<pre><code>def site_creation(request):

    template = loader.get_template('confWeb/create_site.html')
    return HttpResponse(template.render(request))

def cpe_creation(request):
    if request.method == "POST" :
        print(request.POST)
</code></pre>

<p>What I would like to do is to get the value of the input of my form, inside my view "cpe_creation". I tried getting informations from the "request" object but I didn't manage to do that. Maybe I'm lacking very basic HTML skills but I thought the form information would be in the request body, but it wasn't (or didn't look like it).</p>

<p>I also tried using Django forms, but the problem is, I can't control very precisely what the form will look like. If I create an input, I can't tell it the size it's supposed to take or anything like that. </p>

<p>Hence, my questions are the following : 
 - How can I get the data from the submitted form ? 
 - Do I have to do it with Django's Forms ? If I do, how can I control the css class of an input ? </p>

<p>Your field in your form in your template has to have name attribute in order to pass it to your request.</p>

<p>Then you will be able to get it in your view like this:</p>

<p><code>site_name = request.POST.get('site_name')</code></p>

python html django forms