Django - Circular model import issue
Upto Django 1.7:
Use get_model
function from django.db.models
which is designed for lazy model imports.:
from django.db.models import get_model
MyModel = get_model('app_name', 'ModelName')
In your case:
from django.db.models import get_model
Theme = get_model('themes', 'Theme')
Now you can use Theme
For Django 1.7+:
from django.apps import apps
apps.get_model('app_label.model_name')
Remove the import of Theme
and use the model name as a string instead.
theme = models.ForeignKey('themes.Theme')