title: Django Query prefetch_related: 'exceptions.NameError' object does not support item assignment
body: <p>I have one to many relationship table. this is my model</p>
  
  <pre><code>class Pointofsale(models.Model):
     official_receipt = models.CharField(max_length=250,blank=False,null=False)
     transaction_number = models.CharField(max_length=250,unique=True)
     company = models.ForeignKey("User_company")
     customer = models.ForeignKey("Customer")
  
  class Pointofsale_details(models.Model):
     pointofsale = models.ForeignKey(Pointofsale, related_name='pointofsale_details')
     item = models.ForeignKey("Inventory")
     quantity = models.DecimalField(max_digits = 19, decimal_places = 6, default = 0.0) 
  </code></pre>
  
  <p>I want to get the sales with the items in this format</p>
  
  <blockquote>
    <p>{ official_receipt :100,..,etc, pointofsale_details : [ {item1} , {item2} ] }</p>
  </blockquote>
  
  <p>OR ( for summary reporting purposes )</p>
  
  <blockquote>
    <p>[{ official_receipt :100,..,etc, pointofsale_details : [ {item1} , {item2} ] },{ official_receipt :100,..,etc, pointofsale_details : [ {item1} , {item2} ] }]</p>
  </blockquote>
  
  <p>I tried this query for a single query but to no avail:</p>
  
  <pre><code>transaction_details = Pointofsale.objects.filter(company=get_current_company(request)).prefetch_related('pointofsale_details')
  </code></pre>
  
  <p>I get this error</p>
  
  <blockquote>
    <p>'exceptions.NameError' object does not support item assignment</p>
  </blockquote>
  
  <p>Is this is correct or proper way to handle one to many relationships?
  What am I missing?</p>
  
  <p>If this is unclear please feel free to comment below, so i could refine my question. Thank you!</p>
  
  <p>Cheers!</p>
  
  <pre><code>def get_current_company(request,company_obj = False):
      company = request.session.get('company_id',None)
      return company
  </code></pre>
  
  <p>References:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/36721957/django-query-in-one-to-many-relationship">Django query in One to Many relationship</a>   </li>
  <li><a href="https://stackoverflow.com/questions/10322017/how-to-select-many-to-one-to-many-without-hundreds-of-queries-using-django-orm">How to select many to one to many without hundreds of queries using Django ORM?</a></li>
  <li><a href="https://stackoverflow.com/questions/853184/django-orm-selecting-related-set">Django ORM: Selecting related set</a>   </li>
  </ul>