Django: Model Validation Error ManytoManyField -
i error while running syncdb
can't seem figure out issue. please help.
error: 1 or more models did not validate: store.business: reverse query name field 'logo' clashes field 'imagebank.business'. add related_name argument definition 'logo'.
here models:
class business(models.model): business_type = models.manytomanyfield(businesstype) business_service_type = models.manytomanyfield(servicetype) establishment_type = models.foreignkey(establishmenttype) logo = models.foreignkey(imagebank, related_name = '%(class)s_logocreated',) phone = phonenumberfield() address = models.foreignkey(address) website = models.urlfield() name = models.charfield(max_length=64) def __unicode__(self): return self.name class imagebank(models.model): business = models.foreignkey('business', related_name='%(class)s_business') image = models.imagefield(upload_to="images/bank") def url(self): return self.image.url def __unicode__(self): return unicode(self.business) + " : " + unicode(self.image)
store model:
class store(models.model): business = models.foreignkey(business,null=true, related_name='business_creator_set') condition = models.charfield(verbose_name='what customers have do?',max_length = 50) reward = models.charfield(verbose_name='what customers win?',max_length = 50) display = models.booleanfield(default=true) date_created = models.datetimefield(default=datetime.now) def __unicode__(self): return self.condition + ", " + self.reward
try doing this:
... class imagebank(models.model): business = models.foreignkey('business', related_name='%(class)s_business') ....
also, if doesn't work, try changing related_name on business.logo field not logo_id. logo_id database uses field , may having conflict.
Comments
Post a Comment