I am attempting to import a model from another app in django.
The following attempt fails:
from venueadmin.models import VenuePermissions
fails how:
Python is not able to located VenuePermissions, i guess circular reference?
from django.apps import apps
suitscity = apps.get_model('suitsandtablesadmin', 'City')
fails how:
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
.
so then I tried importing using __import__
suitscity = __import__('suitsandtablesadmin.models')
suitscity = getattr(suitscity, 'City')
and
suitscity = __import__('suitsandtablesadmin/models')
suitscity = getattr(suitscity, 'City')
all of which did not work because City
is in a different directory suitsandtablesadmin
How can I make any one of these work?
The directory is as follows:
First I am trying to import models into my venue app models folder
suitsandtables
suitsandtables
__init__
permissions
settings
urls
wsgi
suitsandtablesadmin
__init__
apps
models <-- im trying to import a model from here
serializers
urls
views
suitsusers
__init__
apps
models
etc.....
venueadmin
__init__
apps
models
views
venues
__init__
apps
models <-- into here
views