title: How do I use an UpdateView to update a Django Model?
body: <p>I'm trying to update a model in Django using the class-based generic view UpdateView.</p>
  
  <p>I read the page <a href="https://stackoverflow.com/questions/6181041/updating-user-model-in-django-with-class-based-updateview">Updating User model in Django with class based UpdateView</a> to try and get me started, but I'm getting an error 'WSGIRequest' object has no attribute 'id'</p>
  
  <p>I'm a fresh face to Django, so please be forgiving if I'm doing something stupid.</p>
  
  <p>//urls.py</p>
  
  <pre><code>url(r'^portfolios/update/(?P&lt;id&gt;\d+)/$',PortfoliosUpdateView.as_view()),
  </code></pre>
  
  <p>//views.py</p>
  
  <pre><code>class PortfoliosUpdateView(UpdateView):
      form_class = PortfoliosCreateForm
      model = Portfolios
      template_name = 'portfolios/create.html'
  
      def get(self, request, **kwargs):
          self.object = Portfolios.objects.get(id=self.request.id)
          form_class = self.get_form_class()
          form = self.get_form(form_class)
          context = self.get_context_data(object=self.object, form=form)
          return self.render_to_response(context)
  
      def get_object(self, queryset=None):
          obj = Portfolios.objects.get(id=self.request.id)
          return obj
  </code></pre>
  
  <p>It's mostly just a modified version of the code originally posted, but I thought it'd work. I know that I'm trying to retrieve the id passed as a GET parameter, but that doesn't seem to come through in the request variable. Am I going about this the wrong way?</p>
  
  <p>Thanks</p>
  
  <p>Edit: I think I fixed it, but this may be wrong:
  I changed the lines</p>
  
  <pre><code>self.object = Portfolios.objects.get(id=self.request.id)
  obj = Portfolios.objects.get(id=self.request.id)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>self.object = Portfolios.objects.get(id=self.kwargs['id'])
  obj = Portfolios.objects.get(id=self.kwargs['id'])
  </code></pre>
  
  <p>I could be wrong.</p>