joel goldstick
joel goldstick

Reputation: 4483

ManyToMany model error

I have a Cruise offer class related to a model called SpecialInterest. I now realize that I have the same exact thing going on in my LandOffer model (elsewhere). So I want to get rid of the cruise.SpecialInterest and replace it with the land.SpecialInterest.

This is my error: Error: One or more models did not validate: cruise.cruiseoffer: 'special_interest' has an m2m relation with model land.models.SpecialInterest, which has either not been installed or is abstract.

I dropped the CruiseOffer table, but when I syncdb I fail.

Help?

class CruiseOffer(models.Model):
  id = models.AutoField(primary_key=True)
  name = models.CharField(max_length=300) # Field name made lowercase.
  name_enca = models.CharField(max_length=300, blank=True) # Field name made lowercase.
  name_frca = models.CharField(max_length=300, blank=True) # Field name made lowercase.
  supplier = models.ForeignKey('CruiseSupplier')
  #special_interest = models.ManyToManyField('SpecialInterest')
  special_interest = models.ManyToManyField('land.models.SpecialInterest')

  def __unicode__(self):
    return "%6d %s" % (self.id, self.name,)

Upvotes: 1

Views: 600

Answers (1)

dani herrera
dani herrera

Reputation: 51655

Right syntax is:

from land.models import SpecialInterest
...
class Crui...
    ...
    special_interest = models.ManyToManyField(SpecialInterest)

Upvotes: 1

Related Questions