title: getting data from html files and saving it to models django
body: <p>I have created multiple input fields and when i click submit i need that data to be saved into my database through models.py that i created. However I am unable to understand how to redirect that data from html to django.</p>
  
  <p>This is my html file </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;Cars&lt;/title&gt;
      &lt;h1&gt; Enter sales data to store&lt;/h1&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div&gt;
      &lt;form method="post"&gt;
          {% csrf_token %}
          &lt;label for="billingnumber"&gt;Billing Number:&lt;/label&gt;
          &lt;input type="number" id="billingnumber" name="billingnumber"&gt;&lt;br/&gt;
          &lt;label for="customername" &gt;Customer Name :&lt;/label&gt;
          &lt;input type="text" id="customername" name="customername"&gt;&lt;br/&gt;
          &lt;label for="purchasedate"&gt;Purchase Date:&lt;/label&gt;
          &lt;input type="date" id="purchasedate" name="purchasedate"&gt;&lt;br/&gt;
          &lt;label for="price"&gt;Price:&lt;/label&gt;
          &lt;input type="number" id="price" name="price" &gt;&lt;br/&gt;
          &lt;label for="carcompany"&gt;Car Company:&lt;/label&gt;
          &lt;input type="text" id="carcompany" name="carcompany"&gt;&lt;br/&gt;
          &lt;label for="carmodel"&gt;Car Model:&lt;/label&gt;
          &lt;input type="text" id="carmodel" name="carmodel"&gt;&lt;br/&gt;
          &lt;label&gt;Car Serial Number:&lt;/label&gt;
          &lt;input type="number" id="carserial" name="carserial"&gt;&lt;br/&gt;
          &lt;label for="mfgdate"&gt;Car Manufacturing Date:&lt;/label&gt;
          &lt;input type="date" id="mfgdate" name="mfgdate"&gt;&lt;br/&gt;
          &lt;label for="shippingdate"&gt;Shipping Date:&lt;/label&gt;
          &lt;input type="date" id="shippingdate" name="shippingdate"&gt;&lt;br/&gt;
          &lt;button type="submit" value="submit"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
  &lt;/div&gt;
  &lt;a href="/"&gt;Home&lt;a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my models.py </p>
  
  <pre><code>class cars(models.Model):
      billingnumber = models.BigIntegerField(primary_key=True)
      customer = models.TextField()
      price = models.IntegerField()
      purchasedata = models.DateTimeField()
      carcompany = models.TextField()
      carmodel = models.TextField()
      carserialnumber = models.BigIntegerField()
      carmfgdate = models.DateTimeField()
      shippingdate = models.DateTimeField()
  </code></pre>
  
  <p>These are my url patterns </p>
  
  <pre><code>urlpatterns = [
      url(r"^$", TemplateView.as_view(template_name="index.html"), name="home"),
      url(r"^store/$", TemplateView.as_view(template_name="store.html"), name="store"),
      url(r"^access/$", TemplateView.as_view(template_name="access.html"), name="access"),
      url(r"^about/$", TemplateView.as_view(template_name="about.html"), name="about"),
      ]
  </code></pre>
  
  <p>I am unable to understand how to write views.py however this is how i tried to get data </p>
  
  <pre><code>from django.shortcuts import render
  from django.views.generic import TemplateView
  from django.http import HttpResponseRedirect
  
  # Create your views here.
  from .forms import myform
  from .models import cars
  
  def get_data(request):
          if request.method=="POST":
              form = myform(request.POST)
              if form.is_valid():
                  cars.billingnumber(form)
                  cars.save()
                  return HttpResponse('&lt;html&gt;&lt;body&gt;Data Saved&lt;/body&gt;&lt;/html&gt;')
          else:
              form = myform()
              return render(request, 'sample.html', {'form': form})
  </code></pre>
  
  <p>forms.py </p>
  
  <pre><code>from django import forms
  
  class myform(forms.Form):
      billingnumber = forms.CharField(label="billing number")
  </code></pre>
  
  <p>How can i change these files, I am a novice considering django </p>