I have defined two models where each one references the other, like so:
class User(models.Model):
# ...
loves = models.ManyToManyField(Article, related_name='loved_by')
class Article(models.Model):
# ...
author = models.ForeignKey(User)
You see, the problem is both classes references each other. No matter in what order these two classes are implemented, python always raises NameError
exception, complaining either one class is not defined.