in my venues
app model
file I am dynamically adding models I need to do work.
from django.apps import apps
state = apps.get_model('suitsandtablesadmin', 'State')
suitscity = apps.get_model('suitsandtablesadmin','City')
suitsneighboorhood = apps.get_model('suitsandtablesadmin', 'Neighborhood')
venuetypes = apps.get_model('suitsandtablesadmin', 'VenueTypes')
venueseatingtypes = apps.get_model('venueadmin', 'SeatingTypes')
costofvenue = apps.get_model('venueadmin', 'VenueCost')
venuecusines = apps.get_model('venueadmin', 'Cusines')
roomprivacy = apps.get_model('venueadmin', 'Roomprivacy')
roomamenities = apps.get_model('suitsandtablesadmin', 'Amenities')
I am doing this because a regular import statement will not work. Python says it can find the model, I am guessing because of circular importing.
I see from this stackoverflow answer that it may be best to import the entire app into the file but how will that help? And is there a better solution? Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
I also have yet to create any type of migrations is that a cause?
Relevant part of the trace back below
`File "/home/ri`ckus/Documents/softwareProjects/211hospitality/suitsandtables/backend/suitsandtablesbackend/virtualsuits/suitsandtables/venues/models.py", line 7, in <module>
state = apps.get_model('suitsandtablesadmin', 'State')
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/suitsandtablesbackend/virtualsuits/local/lib/python2.7/site-packages/django/apps/registry.py", line 193, in get_model
self.check_models_ready()
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/suitsandtablesbackend/virtualsuits/local/lib/python2.7/site-packages/django/apps/registry.py", line 132, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
i tired doing this but it didn't work either
class Venue(models.Model):
def __init__(self):
from django.apps import apps
suitscity = apps.get_model('suitsandtablesadmin', 'City')
suitsneighboorhood = apps.get_model('suitsandtablesadmin', 'Neighborhood')
venueseatingtypes = apps.get_model('venueadmin', 'SeatingTypes')
costofvenue = apps.get_model('venueadmin', 'VenueCost')
venuecusines = apps.get_model('venueadmin', 'Cusines')
roomprivacy = apps.get_model('venueadmin', 'Roomprivacy')
roomamenities = apps.get_model('suitsandtablesadmin', 'Amenities')
name = models.CharField(max_length=200)
# address for display
streetaddress = models.CharField(max_length=200)
streetaddress2 = models.CharField(max_length=200, blank=True, null=True)
city = models.CharField(max_length=200)
state = models.ForeignKey(state, on_delete=models.CASCADE)
....... so on so forth the model continues