Note that there are some explanatory texts on larger screens.

plurals
  1. POtable lebron_entry has no column named slug
    text
    copied!<p>I am new to django .I have been following the book Practical Django Projects for learning it. I am creating a weblog as mentioned in the book. I have followed all the steps for writing the Entry model. When the try to add an entry from the admin interface I get the error </p> <pre><code> DatabaseError at /adminlebron/entry/add/ table lebron_entry has no column named slug </code></pre> <p>After searching for a bit I found that I ran syncdb before creating the model fully and from the django documentation I found that Syncdb will not alter existing tables . After that I found South( <a href="http://south.aeracode.org/" rel="nofollow">http://south.aeracode.org/</a> ) and I tried using it , but i am still getting the same error. </p> <p>This is my Entry Model</p> <pre><code>class Entry(models.Model): STATUS_CHOICES = ( (1,'Live'), (2,'Draft'), ) title = models.CharField(max_length=250) excerpt = models.TextField(blank=True) body = models.TextField() pub_date = models.DateTimeField(default=datetime.datetime.now) slug = models.SlugField(help_text="Slug") author = models.ForeignKey(User) enable_comments = models.BooleanField(default=True) featured = models.BooleanField(default=False) status = models.IntegerField(choices=STATUS_CHOICES,default=1) categories = models.ManyToManyField(Category) tags = TagField() excerpt_html = models.TextField(editable=False,blank=True) body_html = models.TextField(editable=False,blank=True) def save(self): self.body_html = markdown(self.body) if self.excerpt: self.excerpt_html = markdown(self.excerpt) super(Entry,self).save() class Meta: verbose_name_plural = "Entries" ordering = ['-pub_date'] class Admin: pass def __unicode__(self): return self.title def get_absolute_url(self): return "/weblog/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(),self.slug) </code></pre> <p>This is the output of sqlall</p> <pre><code>BEGIN; CREATE TABLE "lebron_category" ( "id" integer NOT NULL PRIMARY KEY, "title" varchar(250) NOT NULL, "slug" varchar(50) NOT NULL UNIQUE, "description" text NOT NULL ) ; CREATE TABLE "lebron_entry_categories" ( "id" integer NOT NULL PRIMARY KEY, "entry_id" integer NOT NULL, "category_id" integer NOT NULL REFERENCES "lebron_category" ("id") UNIQUE ("entry_id", "category_id") ) ; CREATE TABLE "lebron_entry" ( "id" integer NOT NULL PRIMARY KEY, "title" varchar(250) NOT NULL, "excerpt" text NOT NULL, "body" text NOT NULL, "pub_date" datetime NOT NULL, "slug" varchar(50) NOT NULL, "author_id" integer NOT NULL REFERENCES "auth_user" ("id"), "enable_comments" bool NOT NULL, "featured" bool NOT NULL, "status" integer NOT NULL, "tags" varchar(255) NOT NULL, "excerpt_html" text NOT NULL, "body_html" text NOT NULL ) ; CREATE INDEX "lebron_entry_56ae2a2a" ON "lebron_entry" ("slug"); CREATE INDEX "lebron_entry_337b96ff" ON "lebron_entry" ("author_id"); COMMIT; </code></pre> <p>It appears that the column slug is there in the table after all. I don't want to recreate the db is there any other way to correct this? The name of my app is lebron</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload