[Django1.8.5] About migrate

34 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.

    I was upgrade django from 1.5 to 1.8.

    My Django environment now is : Django 1.8.5 with python 2.7.10

   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 cannot syncdb ,either. 

    My auth apps was included in a core floder.

    Help me fix the bug, please. I was coming unstuck for a mouth.     

aRkadeFR

unread,
Nov 17, 2015, 10:41:58 AM11/17/15
to django...@googlegroups.com
Hey,

What is the code of your managers and what's the full stacktrace?
You can use dpaste.de as a pastebin :)

For the related field, iirc, it's recommended to reference them with a  string.

try to change this
cards = models.ManyToManyField(Card, blank=True)
by:
cards = models.ManyToManyField('app.Card')
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a811320a-efb8-425f-aa0c-bd68df4191f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
aRkadeFR

Dennis Liou

unread,
Nov 17, 2015, 9:32:35 PM11/17/15
to Django users
Thanks, it works , I still need to debug another.

I use 

cards = models.ManyToManyField('Card')

Thanks for help.

Dennis Liou於 2015年11月17日星期二 UTC+8下午8時02分56秒寫道:

Dennis Liou

unread,
Nov 17, 2015, 10:03:49 PM11/17/15
to Django users
Although it can syncdb, but I cannot reference ant thing...

Dennis Liou於 2015年11月17日星期二 UTC+8下午8時02分56秒寫道:
Reply all
Reply to author
Forward
0 new messages