byrdr
byrdr

Reputation: 5467

Django no such column error in admin

I'm returning an error in Django when a field is added to my Catalog model. The model work fine with just the "Article" foreign key, but when the "Annual" foreign key is added I get the following error in the admin:

no such column: subscriber_catalog.annual_items_id 

What would be causing this error?

class Annual(models.Model):
    year_id = models.IntegerField(max_length=4)
    start_date = models.CharField(max_length=6)
    end_date = models.CharField(max_length=6)
    def __unicode__(self):
        return unicode(self.year_id)

class Annual_Issue(models.Model):
    annual_id = models.ForeignKey(Annual, related_name='annual_ids')
    issue_id = models.ForeignKey(Issue, related_name='issues')
    def __unicode__(self):
        return self.annual_id

class Article(models.Model):
    title = models.CharField(max_length=200)
    abstract = models.TextField(max_length=1000, blank=True)
    full_text = models.TextField(blank=True)
    proquest_link = models.CharField(max_length=200, blank=True, null=True)
    ebsco_link = models.CharField(max_length=200, blank=True, null=True)

    def __unicode__(self):
        return self.title


class Catalog(models.Model):
    issue_items = models.ForeignKey(Issue, related_name='catalogissue')
    annual_items = models.ForeignKey(Annual, related_name='catalogannual')

Upvotes: 0

Views: 338

Answers (1)

cdvv7788
cdvv7788

Reputation: 2089

It is looking for annual_items_id, but in your models the only field named in a simmilar way is called annual_id...check your field naming and if you are applying migrations properly

Upvotes: 2

Related Questions