title: Django AttributeError in vews.py 'NoneType' object has no attribute 'all'
body: <p>I am getting the below error in views.py and I am not able to figure out the reason for it. Please help.</p>
  
  <pre><code>Request Method: GET
  Request URL:    http://localhost:8000/tribalrights/
  
  Django Version: 1.3.1
  Exception Type: AttributeError
  Exception Value:    'NoneType' object has no attribute 'all'
  Exception Location: /home/gunjan/tribalrights/tr/views.py in home, line 70
  Python Executable:  /usr/bin/python
  Python Version: 2.7.3
  </code></pre>
  
  <p>Below is the function which is being called in views.py . Line 70 starts just next line to for declaration.</p>
  
  <pre><code>def home(request):
      atrocities = Atrocity.objects.all()
      cities = City.objects.all()
      for atrocity in atrocities:
         #this is line 69.below is line 70. 
         cities = atrocity.location.all()
      return render_to_response('tr/home.html', {
              'cities' : cities,
          })
  </code></pre>
  
  <p>Below in the definitions for City and Atrocity attributes in models.py</p>
  
  <pre><code>class Atrocity(models.Model):
      name = models.CharField(max_length=255)
      dateTimeOccurred = models.DateTimeField ( null=True, blank=True )
      persons = models.ManyToManyField ( Person, null=True, blank=True )
      atrocityType = models.ForeignKey(AtrocityType)
      description = models.CharField(max_length=255)
      location = models.ForeignKey(City, null=True, blank=True)
      def __unicode__(self):
          return self.name
  
  class City(models.Model):
      name = models.CharField(max_length=255)
      district = models.ForeignKey(District)
      latitude = models.DecimalField(max_digits=13, decimal_places=10, null=True, blank=True)
      longitude = models.DecimalField(max_digits=13, decimal_places=10, null=True, blank=True)
      def __unicode__(self):
          return self.name
  </code></pre>