2013-04-08 31 views
0

我有以下2种型号,我想给他们一个多对多的关系链接:按名称,无法在执行syncdb

  • 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') 
    

正如您所看到的,它们位于不同的应用程序中,并且Video也具有用于HRuser的ForeignKey。 为了避免圆形进口在www/hruser/models.py我尝试使用一个懒惰的关系,定义在文档here,但它提出了在执行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. 

到目前为止,我曾尝试:

  • 导入我的视频模式在Python外壳,其工作
  • 从MySQL切换(5.6.10)对于SQLite(3.7.12)
  • 从Django的1.5切换到Django的1.4
  • HRuser.video字段更改为一个简单的ForeignKey的领域
  • 来看待django.core.management.validation

所有这一切都没有改变任何东西,以我的问题的根源,所以无论是我不理解正确的文档,或该文件是错误的,但无论如何,任何帮助将不胜感激。

回答

0

如文档链接中所述,将目标引用为字符串的方式为"appname.Model"。所以它应该是"pandastream.Video"

+0

哇,谢谢,我不能相信我一直都在思念。 – baptistemillou 2013-04-08 11:04:31