I am wondering if it is possible to define a foreign key in the models.py file in Django, which is a link to a table in another application?
In other words, I have two applications called cf and profiles, and in cf / models.py I have (among other things):
class Movie(models.Model): title = models.CharField(max_length=255)
and in the profiles /models.py I want to have:
class MovieProperty(models.Model): movie = models.ForeignKey(Movie)
But I canβt make it work. I tried:
movie = models.ForeignKey(cf.Movie)
and I tried to import cf.Movie at the beginning of models.py, but always get errors, for example:
NameError: name 'User' is not defined
Am I breaking the rules by trying to link the two applications together this way, or did I just get the syntax wrong?
python django django-models
Ben Nov 27 '08 at 13:24 2008-11-27 13:24
source share