I'm wondering if it's possible to define a foreign key in a models.py file in Django that is a reference to a table in another app?
In other words, I have two apps, called cf and profiles, and in cf/models.py I have (amongst other things):
title = models.CharField(max_length=255)
movie = models.ForeignKey(Movie)
movie = models.ForeignKey(cf.Movie)
NameError: name 'User' is not defined
According to the docs, your second attempt should work:
To refer to models defined in another application, you must instead explicitly specify the application label. For example, if the Manufacturer model above is defined in another application called production, you'd need to use:
class Car(models.Model): manufacturer = models.ForeignKey('production.Manufacturer')
Have you tried putting it into quotes?