title: Save data to database using Django forms
body: <p>my Save button does not save the user entered data into the database in a django form, where is the problem?</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Cemetery(models.Model):
      id = models.AutoField(primary_key=True)
      name=models.CharField(verbose_name="Cemetery Name",max_length=100)
      city=models.CharField(max_length=30)
      zipcode=models.CharField(max_length=5)
      date_created=models.DateTimeField(editable=False, auto_now_add=True)
      date_modified= models.DateTimeField(editable=False, auto_now=True)
      created_by=models.ForeignKey('auth.User')
  
      def __str__(self):
          return  str(self.id) +'-' + self.name + ' -  ' + self.city
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class CemeteryForm(forms.ModelForm):
       class Meta:
          model=Cemetery
          fields=('name','city','zipcode',)
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def cemetery_add(request):
      if request.method=="POST":
          form=CemeteryForm(request.POST)
          if form.is_valid():
              cemetery=form.save(commit=False)
              cemetery.name=request.name
              cemetery.city=request.city
              cemetery.zipcode=request.zipcode
              cemetery.created_by=request.user
              cemetery.date_created=timezone.now()
              cemetery.save()
              return redirect('cemetery_list')
      else:
          form=CemeteryForm
      return render(request,'heaven/edit_cemetery.html',{'form':form})
  </code></pre>
  
  <p><strong>template</strong></p>
  
  <pre><code>{% extends 'heaven/base.html' %}
  
  {% block content %}
      &lt;!-- Edit Cemetery --&gt;
      &lt;h2&gt;New Cemetery&lt;/h2&gt;
      &lt;form method="POST" class="cemetery-form"&gt;{% csrf_token %}
          {{ form.as_p }}
          &lt;button type="submit" class="save btn btn-default"&gt;Save&lt;/button&gt;
      &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p>when I push the save button, this is the error I receive:
  AttributeError at /cemetery_add/
  'WSGIRequest' object has no attribute 'name'</p>