0

I am trying to find a solution to this error I keep getting:

column posts_post.slug does not exist

LINE 1: SELECT "posts_post"."id", "posts_post"."title", "posts_post"...

Does anyone know what might be causing this?

Here is the full error output: http://dpaste.com/813336/

    from django.db import models
    from django.contrib.auth.models import User
    from datetime import datetime

    class Category(models.Model):
    name = models.CharField(max_length=60)
    def __unicode__(self):
        return self.name

   class Tags(models.Model):
    name = models.CharField(max_length=60)
    def __unicode__(self):
        return self.name

   class Post(models.Model):
    title = models.CharField(max_length=120)
    slug = models.SlugField(max_length=120, unique=True)
    description = models.TextField()
    body = models.TextField()
    published = models.DateTimeField(default=datetime.now)
    categories = models.ForeignKey(Category)
    tags = models.ManyToManyField(Tags)
    def __unicode__(self):
        return self.title
    class Meta:
        ordering = ['-published']
    def get_absolute_url(self):
         return "/%s/%s/%s" % (self.published.year, self.published.month, self.slug)

2 Answers 2

2

Did you add the SlugField later? If so, a syncdb does not update existing database tables. Delete the entire table and re-do the syncdb.

Sign up to request clarification or add additional context in comments.

Comments

1

The error is quite simple - you don't have the column slug in the given database table. If you added it later in the model, syncdb doesn't modify the table (this operation can not be done automatically). For this purpose, use the South application which is a must have application for Django.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.