title: Edit Model data using ModelForm: ModelForm validation error
body: <p>I am working on my first django app. I am building an app that allows the user to rate beer. I want my user to be able to edit an entry they've already created. I take them to a ModelForm, and ask for their entry. When the POST method is called, my data is invalid. Here is my model.py:</p>
  
  <pre><code>from django.db import models
  
  
   class Rating(models.Model):
      beer_name = models.TextField()
      score = models.DecimalField(max_digits=2, decimal_places=1)
      notes = models.TextField(blank=True)
      brewer = models.TextField(blank=True)
  </code></pre>
  
  <p>and forms.py:</p>
  
  <pre><code>from django import forms
  from ratings.models import Rating
  
  
  class RatingForm(forms.ModelForm):
      class Meta:
          model = Rating
          fields = ['beer_name', 'score', 'notes', 'brewer']
  </code></pre>
  
  <p>Here is the views.py of my edit function:</p>
  
  <pre><code>def edit(request, row_id):
      rating = get_object_or_404(Rating, pk=row_id)
      if request.method == "POST":
          form = RatingForm(request.POST, instance=rating)
          if form.is_valid():
              form.save()
              return redirect(home)
          else:
              return HttpResponse("Invalid entry.")
      else:
          context = {'form': rating}
          form = RatingForm(instance=rating)
          return render(
              request,
              'ratings/entry_def.html',
              context
          )
  </code></pre>
  
  <p>However, every time the POST is called I get an "Invalid entry." HttpResponse, meaning my form.is_valid() is being returned False. Here is my template:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block content %}
    &lt;div class="container-fluid"&gt;
      &lt;div class="row"&gt;
        &lt;div class="col-sm-10 col-sm-offset-1"&gt;
          &lt;h2&gt;Edit Rating&lt;/h2&gt;
          &lt;form role="form" method="post"&gt;
            {% csrf_token %}
            &lt;p&gt;Beer Name: &lt;textarea&gt;{{ form.beer_name }}&lt;/textarea&gt;&lt;/p&gt;
            &lt;p&gt;Score: &lt;input type="text" name="BeerScore" value="{{ form.score }}"&gt;&lt;/p&gt;
            &lt;p&gt;Notes: &lt;textarea&gt;{{ form.notes }}&lt;/textarea&gt;&lt;/p&gt;
            &lt;p&gt;Brewer: &lt;textarea&gt;{{ form.brewer }}&lt;/textarea&gt;&lt;/p&gt;
            &lt;p&gt;&lt;button type="submit" class="save btn btn-primary"&gt;Save&lt;/button&gt;&lt;/p&gt;
            &lt;p&gt;&lt;button type="reset" class="btn btn-primary"&gt;Cancel&lt;/button&gt;&lt;/p&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>So when I press my Save button, I am getting the response. Here is my edit url in urls.py:</p>
  
  <pre><code>urlpatterns = [
      ...
      url(r'rating/edit/(?P&lt;row_id&gt;[0-9]+)/$', edit , name='rating-edit'),
  ]
  </code></pre>