title: Django - Update View, creating new Objects instead of updating,
body: <p>I am trying to use Update view in django, in the simplest manner, but it is not being updated, rather a new object of the model is being created in the database. I have done the same thing for another model Track, and its working fine. I feel it might be something trivial that might be causing the problem.</p>
  
  <p>I am modifying the PK of the model here. Could this be the reason?</p>
  
  <p><strong>View:</strong></p>
  
  <pre><code>    from django.views.generic.edit import UpdateView
      from musictracker.models.datamodels.Genre import Genre
  
      class EditGenre(UpdateView):
  
          model = Genre
          template_name = "editGenre.html"
          fields = ['name']
  </code></pre>
  
  <p><strong>Template:</strong></p>
  
  <pre><code>{% extends 'base.html' %} {% load addcss %} {% block content %}
  &lt;div id="regContainer"&gt;
      &lt;ul&gt;
          &lt;!-- {% if form.errors %} {{form.errors}} {% endif %} --&gt;
      &lt;/ul&gt;
      &lt;div class="form-group"&gt;
          &lt;form method="post" action=""&gt;
              {% csrf_token %} 
  
              {% for field in form %}
  
              &lt;label class="control-label" for="form-control input-sm"&gt;{{field.label_tag }}&lt;/label&gt;
              &lt;br /&gt; {{field|addcss:"form-control input-sm"}}
              &lt;br /&gt; 
  
              {% endfor %}
              &lt;input type="submit" id="register" value="Edit Genre" class="btn btn-default"&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p><strong>URLS.py</strong></p>
  
  <pre><code>from django.conf.urls import url
  from django.contrib import admin
  
  ''' View Imports '''
  from views import TrackList
  from views import AddTrack
  from views import TrackDetail
  from views import EditTrack
  
  from views import GenreList
  from views import GenreDetail
  from views import AddGenre
  from views import EditGenre
  
  
  urlpatterns = [
      url(r'^tracks/', TrackList.as_view(),name='all-tracks'),
      url(r'^addTrack/', AddTrack.as_view(),name='add-tracks'),
      url(r'^editTrack/(?P&lt;pk&gt;[0-9]+)', EditTrack.as_view(),name='edit-track'),
      url(r'^track/(?P&lt;pk&gt;[0-9]+)', TrackDetail.as_view(),name='track'),
  
      url(r'^genres/', GenreList.as_view(),name='all-genres'),
      url(r'^addGenre/', AddGenre.as_view(),name='add-genre'),
      url(r'^editGenre/(?P&lt;pk&gt;[a-zA-Z0-9]+)', EditGenre.as_view(),name='genre'),
      url(r'^genre/(?P&lt;pk&gt;[a-zA-Z0-9]+)', GenreDetail.as_view(),name='genre'),
  ]
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>class Genre(models.Model):
      '''
      This is a model for Genres
      '''
  
      name = models.CharField(max_length=20,primary_key=True,editable=True)
      songcount = models.IntegerField()
  
      def __unicode__(self):
          return self.name
  
  
      def get_absolute_url(self):
          return reverse('genre', kwargs={'pk': self.pk})
  </code></pre>