title: How get Instance in Django ModelForm
body: <p>I'm trying to update a model in Django using the class-based generic view UpdateView.But i have some instance problem.When i click submit button id is  pass to update form , but instances isn't</p>
  <p>i am new in django ,so please be forgiving if I'm doing something stupid.</p>
  <p><strong>urls.py</strong></p>
  <pre><code>app_name = 'inventory'
  urlpatterns = [
  url(r'^$', views.IndexView.as_view(), name='index'),
  
  url(r'^inventory/(?P&lt;pk&gt;[0-9]+)/delete/$', views.HardwareDelete.as_view(), name='hardware-delete'),
  url(r'^inventory/update/(?P&lt;pk&gt;[0-9]+)/$', views.HardwareUpdate.as_view(), name='hardware-update'),
  # url(r'^/inventory/add$', views.InventoryAdd.as_view(), name='add-inventory'),]
  </code></pre>
  <p><strong>models.py</strong></p>
  <pre><code>class Hardwares(models.Model):
      hardware_unit=models.CharField(max_length=100)
      hardware_model=models.CharField(max_length=100)
      hardware_subsystem=models.CharField(max_length=100)
      hardware_serial_number=models.CharField(max_length=1000)
      hardware_manufacturer = models.CharField(max_length=1000)
      hardware_operating_system = models.CharField(max_length=1000)
      hardware_quantity = models.IntegerField(default=1, validators=[MinValueValidator(1)])
  
      def get_absolute_url( self ):
          return reverse('inventory:index')
  
      def __str__(self):
          return self.hardware_serial_number+&quot;  &quot;+self.hardware_model+&quot;  &quot;+self.hardware_unit+&quot;  &quot;+str(self.hardware_quantity)
  </code></pre>
  <p><strong>forms.py</strong></p>
  <pre><code>class HomeForm(forms.ModelForm):
      hardware_unit = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Hardware Unit Name..', }))
      hardware_model = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Model Name...', }))
      hardware_subsystem = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', }))
      hardware_serial_number = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', }))
      hardware_manufacturer = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Manufacturer Company Name', }))
      hardware_operating_system = forms.CharField(
      widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Operating System Name', }))
      hardware_quantity = forms.IntegerField(validators=[MinValueValidator(1)],
      widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Quantity of Harware', }))
  
      class Meta:
          model = Hardwares
          fields = {'hardware_unit', 'hardware_model', 'hardware_subsystem', 'hardware_serial_number',
                'hardware_manufacturer', 'hardware_operating_system', 'hardware_quantity', }
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>class HardwareUpdate(UpdateView):
      model = Hardwares
      template_name = 'inventory/update_form.html'
      form_class = HardwareForm
  </code></pre>
  <p><strong>update.form html</strong></p>
  <pre><code>{% extends 'inventory/basic_menu.html' %}
  {% block body %}
  
                  &lt;form class=&quot;form-horizontal&quot; action=&quot;&quot; method=&quot;post&quot;
                        enctype=&quot;multipart/form-data&quot;&gt;
                      {% csrf_token %}
  
  
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label class=&quot;col-md-3 control-label&quot;&gt;Hardware
                              Unit&lt;/label&gt;
                          &lt;div class=&quot;col-md-9&quot;&gt;
                              {{ form.hardware_unit }}
  
                              &lt;span class=&quot;help-block&quot;&gt;Hardware Unit Name eg.:  Firewall , Notebook , Phone&lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
               //Have more 8 form groups like this
  
  {% endblock body %}
  </code></pre>
  <p>Here is some part of my update_form.html .The rest part is the same</p>
  <h1>SOLUTION</h1>
  <p>Problem occured from my update button form's method.its method was &quot;post&quot;.I change it to &quot;get&quot; method and problem solved.Don't need to overried Updateview post function.Thanks to all for solutions.</p>
  <blockquote>
  <p><strong>BEFOR</strong></p>
  <pre><code>        &lt;form action=&quot;{% url 'inventory:hardware-update' hardwares.id %}&quot;
          method=&quot;post&quot; style=&quot;display: inline;&quot;&gt;
                              {% csrf_token %}...........
  </code></pre>
  <p><strong>AFTER</strong></p>
  <pre><code>        &lt;form action=&quot;{% url 'inventory:hardware-update' hardwares.id %}&quot;
          method=&quot;get&quot; style=&quot;display: inline;&quot;&gt;
                              {% csrf_token %}...........
  </code></pre>
  </blockquote>