185👍
✅
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?
29👍
It is also possible to pass the class itself:
from django.db import models
from production import models as production_models
class Car(models.Model):
manufacturer = models.ForeignKey(production_models.Manufacturer)
- [Django]-Django: How can I create a multiple select form?
- [Django]-VueJS + Django Channels
- [Django]-When to create a new app (with startapp) in Django?
10👍
OK – I’ve figured it out. You can do it, you just have to use the right import
syntax. The correct syntax is:
from prototype.cf.models import Movie
My mistake was not specifying the .models
part of that line. D’oh!
👤Ben
- [Django]-Substring in a django template?
- [Django]-Authenticate by IP address in Django
- [Django]-How do I deploy Django on AWS?
Source:stackexchange.com