title: Retreiving an object id from a queryset in Django
body: <p>I have a contract table in my database, the contracts are based mainly on a listing and two users. When creating the contract I want to check if the contract already exists and if so redicrect the user(s) to the created contract. Here is the code in my view:</p>
  
  <pre><code>def create_proposal (request, conversation_pk):
  existing_proposal = Contract.objects.filter(users__in=[user_1, user_2]).filter(listing_id=listing).values_list('id', flat=True)
  </code></pre>
  
  <p>Then I redirect using:</p>
  
  <pre><code>    if existing_proposal.exists():
      messages.success(request, "the proposal already exists")
      return HttpResponseRedirect(reverse('agreement:agreement', kwargs={'pk': existing_proposal[0].pk}))
  </code></pre>
  
  <p>However, I am getting the following error:</p>
  
  <pre><code>AttributeError at /en/agreement/create_proposal/32
  'int' object has no attribute 'pk'
  </code></pre>