title: Django: Cannout update model through form POST, only Shell
body: <p><strong>What are you trying to accomplish? (Please include sample data.)</strong></p>
  
  <p>I am trying to create a form in Django that takes in data and saves them in a database.</p>
  
  <p><strong>Paste the part of the code that shows the problem. (Please indent 4 spaces.)</strong></p>
  
  <blockquote>
    <p>index4.html</p>
  </blockquote>
  
  <pre><code>    &lt;form action="post_url/" method="post"&gt;
          {% csrf_token %}
          {{ form }}
          &lt;input type="submit" value="Submit" /&gt;
      &lt;/form&gt;
  </code></pre>
  
  <blockquote>
    <p>urls.py (project folder)</p>
  </blockquote>
  
  <pre><code>from django.conf.urls import url
  from django.contrib import admin
  from exercises.views import *
  
  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^numbers/', numbers, name="numbers"),
      url(r'^about/', about, name="about"),
      url(r'^post_url/$', post_treasure, name='post_treasure')
  ]
  </code></pre>
  
  <blockquote>
    <p>views.py</p>
  </blockquote>
  
  <pre><code>from django.shortcuts import render
  from django.http import HttpResponse
  from .models import Treasure
  from .forms import TreasureForm
  
  def numbers(request):
      treasures = Treasure.objects.all()
      form = TreasureForm()
      return render(request, 'index4.html', {'treasures': treasures, 'form':form})
  
  def about(request):
      return render(request, "about.html", {})
  
  def q1(request):
      return HttpResponse("What is the average age of a dinosaur?")
  
  def post_treasure(request):
      form = TreasureForm(request.POST)
      if form.is_valid():
          treasure = Treasure(name = form.cleaned_data['name'],
                              value = form.cleaned_data['value'],
                              material = form.cleaned_data['material'],
                              location = form.cleaned_data['location'],
                              img_url = form.cleaned_data['img_url'])
          treasure.save()
      return HttpResponseRedirect('/')
  </code></pre>
  
  <blockquote>
    <p>forms.py</p>
  </blockquote>
  
  <pre><code>from django import forms
  from .models import Treasure
  
  # class TreasureForm(forms.ModelForm):
  #   class Meta:
  #       model = Treasure
  #       fields = ['name', 'value', 'location', 'material']
  #       if form.is_valid():
  #           form.save(commit = True)
  #       return HttpResponseRedirect('/')
  
  class TreasureForm(forms.Form):
      name = forms.CharField(label='Name', max_length=100)
      value = forms.DecimalField(label='Value', max_digits=10, decimal_places=2)
      material = forms.CharField(label='Material', max_length=100)
      location = forms.CharField(label='Location', max_length=100)
      img_url = forms.CharField(label='Image URL', max_length=100)
  </code></pre>
  
  <blockquote>
    <p>models.py</p>
  </blockquote>
  
  <pre><code>from django.db import models
  
  class Treasure(models.Model):
      name = models.CharField(max_length=100)
      value = models.DecimalField(max_digits=10, decimal_places=2)
      material = models.CharField(max_length=100)
      location = models.CharField(max_length=100)
      img_url = models.CharField(max_length=100)
  </code></pre>
  
  <p><strong>What do you expect the result to be? &amp;&amp; What is the actual result you get? (Please include any errors.)</strong>
  After filling in the form, I expected the Treasure model class to contain a new Treasure object. This does not occur if I confirm it using the python shell, but also through the list of treasures on the index4.html template. The only way this works is if I manually add a Treasure using the python shell</p>
  
  <p>Errors: N/A, program compiles successfully</p>