title: Django 3: get_object_or_404 for UpdateView
body: <p>I have a problem:
  I'd like to update a specific data/product, but a can't use <strong>get_object_or_404</strong></p>
  <p><strong>views.py</strong></p>
  <pre><code>from django.shortcuts import render,get_object_or_404
  from django.http import HttpResponseRedirect, HttpResponse
  from django.urls import reverse
  from django.contrib import messages
  from django.views.generic import (
      UpdateView,
      DeleteView
  )
  
  from product.models import Product
  from pages.forms import ProductForm
  
  def ProductUpdateView(request, pk): 
      # queryset = Product.objects.all()[0].pk_id &lt;-- I tried this
      # queryset = Product.objects.get() &lt;-- and this
  
      queryset = Product.objects.all()
  
      product1 = get_object_or_404(queryset, pk=pk)
      #product1 = get_object_or_404(Product, pk=pk) &lt;-- and this
       
      if request.method == 'POST':
  
          productUpdate_form = ProductForm(data=request.POST,files=request.FILES,instance=request.product1))
          # Check to see the form is valid
          if productUpdate_form.is_valid(): # and profile_default.is_valid() :
              # Sava o produto
              productUpdate_form.save()
              # Registration Successful! messages.success
              messages.success(request, 'Produto Modificado com Sucesso')
              #Go to Index
              return HttpResponseRedirect(reverse('index'))
          else:
              # One of the forms was invalid if this else gets called.
              print(productUpdate_form.errors)
  
      else:
          # render the forms with data.
          productUpdate_form = ProductForm(instance=request.product1)
      
      
      context = {'productUpdate_form': productUpdate_form,}
      return render(request, 'base/update.html',context)
  </code></pre>
  <p><strong>urls.py</strong></p>
  <pre><code>from django.urls import include, path
  from pages.views import (ProductListView,
                          ProductUpdateView,
                          ProductDeleteView)
  
  urlpatterns = [
      path('listProduct/', ProductListView, name='listProduct'),
      path('&lt;int:pk&gt;/update/', ProductUpdateView, name='product-update'), &lt;--this link is ok
  ]
  </code></pre>
  <p><strong>Error:</strong></p>
  <p>AttributeError at /1/update/</p>
  <p>'WSGIRequest' object has no attribute 'product1'</p>
  <p>Request Method:     GET
  Request URL:    <a href="http://127.0.0.1:8000/1/update/" rel="nofollow noreferrer">http://127.0.0.1:8000/1/update/</a>
  Django Version:     3.1.1
  Exception Type:     AttributeError
  Exception Value:</p>
  <p>'WSGIRequest' object has no attribute 'product1'</p>
  <p>Exception Location:     C:\Users\rodrigo negao\Desktop\PROJETOS\MyDjango\ECAPI\pages\views.py, line 78, in ProductUpdateView
  Python Executable:  C:\Users\rodrigo negao\Anaconda3\envs\ECAPI\python.exe
  Python Version:     3.8.5
  Python Path:</p>
  <p>['C:\Users\rodrigo negao\Desktop\PROJETOS\MyDjango\ECAPI',
  'C:\Users\rodrigo negao\Anaconda3\envs\ECAPI\python38.zip',
  'C:\Users\rodrigo negao\Anaconda3\envs\ECAPI\DLLs',
  'C:\Users\rodrigo negao\Anaconda3\envs\ECAPI\lib',
  'C:\Users\rodrigo negao\Anaconda3\envs\ECAPI',
  'C:\Users\rodrigo negao\Anaconda3\envs\ECAPI\lib\site-packages']</p>
  <p>Server time:    Thu, 01 Oct 2020 21:36:44 -0300.</p>
  <p><strong>So,</strong> I can't compare <strong>pk</strong> in <strong>get_object_or_404</strong>, I need it to found and use a specific data/product.</p>
  <p>What other way to use <strong>get_object_or_404</strong> or compare link/pk and data/product ?</p>
  <p>Help plz.</p>