[Django 1.8.5] models bug when migrate.

24 views
Skip to first unread message

Dennis Liou

unread,
Nov 17, 2015, 7:02:56 AM11/17/15
to Django users
Hi :
  
    I am new in Django, and I meet a bug.

    My Django environment is : Django 1.8.5 with python 2.7.10

    I was upgrade my django from 1.5 to 1.8

    This is my auth models:
     
Class Card(models.Model):
    cardgroup = models.CharField(_('CardGroup'), max_length=60)
    cardname = models.CharField(_('CardName'), max_length=60)
    disabled = models.BooleanField(_('disabled'), default=False)
    objects = CardManager()

    class Meta:
        unique_together = (cardgroup', 'cardname')
    def __unicode__(self):
        return self.name
    @property
    def name(self):
        return '%s_%s' % (.self.cardgroup, self.cardname)

Class Factory(models.Model):
  sort = models.CharField(_('Short Name'), max_length=20, unique=True)
  address = models.CharField(_('Factory address'), max_length=20)
  cards = models.ManyToManyField(Card, blank=True)

  def __unicode__(self):
        return self.short


  After "#python manage.py migrate" twice , I got a error:

  ValueError: Lookup failed for model referenced by field core.auth.Factory.card:core.auth.core.auth.Card

    Because of that, I can not syncdb ,either. 

PS. My core apps were in a "core" folder.

    Help me fix the bug, please. I was coming unstuck for a mouth.
Reply all
Reply to author
Forward
0 new messages