title: Python NameError (Django)
body: <p>This is code in models.py </p>
  
  <pre><code>class Package(models.Model):
    name=models.CharField(max_length=300)
    version=models.CharField(max_length=300,blank=True)
    home_page=models.URLField(blank=True)
    summary=models.TextField()
    description=models.TextField(blank=True)
    keywords=models.TextField(blank=True)
    categories=models.ManyToManyField(Category,related_name='packages')
  
  
  
  class Category(models.Model):
    topic=models.ForeignKey(Package, related_name="categories")
  </code></pre>
  
  <p>When i try to syncdb it says "NameError Category is not defined" i tried placing class category first and package next this time it says "NameError name Package is not defined". </p>
  
  <p>Please help me out of this problem.</p>
  
  <p>EDIT: 
  Thanks for the help guys, from a very little knowledge of what i know in databases the tutorial here seems wrong <a href="http://toys.jacobian.org/presentations/2007/pycon/tutorials/beginning/" rel="nofollow">http://toys.jacobian.org/presentations/2007/pycon/tutorials/beginning/</a> 
  He has defined the field categories in Packages to be many-to-many and the field in Category topic to be a foreign key to Package ,but a foreign key is a many-to-one relationship, therefore the implementation is flawed. 
  I think django is trying to tell it in its way as "Accessor for field 'topic' clashes with m2m field 'Package.categories'." Reverse query name for field 'topic' clashes with m2m field ' "
  Is that correct? </p>