I have the 2 following models, and I'd like to link them with a ManyToMany relationship :
www/hruser/models.py
from django.db import models
class HRuser(models.Model):
"""Custom user class."""
email = models.EmailField(max_length=60, unique=True, db_index=True)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
video = models.ManyToManyField('www.pandastream.models.Video', related_name='users')
www/pandastream/models.py
from django.db import models
from www.hruser.models import HRuser
class Video(models.Model):
"""Video object, really basic for now."""
video_id = models.CharField(max_length=32, unique=True, db_index=True)
user = models.ForeignKey(HRuser, related_name='videos')
As you can see, they are in a different app, and Video also has a ForeignKey to HRuser.
To avoid a circular import in www/hruser/models.py
I try to use a lazy relationship, as defined here in the docs, but it raises an error on syncdb :
Error: One or more models did not validate:
hruser.hruser: 'video' has an m2m relation with model www.pandastream.models.Video, which has either not been installed or is abstract.
So far, I have tried :
HRuser.video
field to a simple ForeignKey fielddjango.core.management.validation
All of which didn't change anything to my problem, so either I do not understand the documentation correctly or the documentation is wrong, but either way, any help would be appreciated.
The way to reference the target as a string, as explained in that docs link, is as "appname.Model"
. So it should just be "pandastream.Video"
.