title: Django : saving form to database
body: <p>So I have the following model :</p>
  
  <pre><code>class Recipe(models.Model):
          title = models.CharField(max_length=100)
          ingredients = models.TextField(max_length=200,help_text="Put the ingredients required for the recepies here !")
          instructions = models.TextField(max_length=500)
  
          posted_on = models.DateTimeField('Posted On')
  
          def __unicode__(self):
                  return self.title
  </code></pre>
  
  <p>Now what I want to do is that I have a front-end in html called add.html which has a form like: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  
  &lt;head&gt;&lt;title&gt;New Recipe&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Add A new Recipe Here&lt;/h1&gt;
  
  &lt;form action="/recipes/add/" method="post"&gt;
  {% csrf_token  %}
  
  &lt;label&gt;ID&lt;label&gt;
  &lt;input type="number" name="id"&gt;&lt;/input&gt;&lt;br /&gt;
  
  &lt;label&gt;Title &lt;/label&gt;
  &lt;input type ="text" name="title"&gt;&lt;br /&gt;
  
  &lt;label&gt;Ingredients&lt;/label&gt;
  &lt;input type="text" name="ingredients" /&gt;
  &lt;br /&gt;
  
  &lt;label&gt;Instructions &lt;/label&gt;
  &lt;input type="text" name="instructions" /&gt;
  ...
  </code></pre>
  
  <p>Here is how I am saving the form using <code>ModelForm</code>: </p>
  
  <pre><code>def add(request):
          if request.method == 'POST':
                  form = RecipeForm(request.POST)
                  if form.is_valid():
  
                          form.save()
                          #redirect
                          return HttpResponse("Thank you")
                  else:
                          return HttpResponse("Form Not Valid")
          else:
                  form = RecipeForm()
  
                  context = Context({'form':form,})
                  context.update(csrf(request))
                  template = loader.get_template('myApp/add.html')
                  return HttpResponse(template.render(context))
  </code></pre>
  
  <p>When I run this I always get <code>"form Invalid"</code>
  So now my problem is, Should the html form add.html have the EXACT mappings as my model  Recipe ?<br>
  If yes  ,then    </p>
  
  <ol>
  <li>How do I add the corresponding <code>types</code> in the html form (for <code>posted_on</code>) ?    </li>
  <li>How do I handle the <code>id</code> that is implicitly created by <code>syncdb</code>?    </li>
  <li>Is there any alternative ?    </li>
  </ol>
  
  <p>I have just started to learn Django</p>