I was implementing tags on my blog and ran into this problem:
Under the administration page I can create and view tags. I can also
view a list of entries and try and create an entry. When I try and
create an entry I can fill out the entry form and save it. The data is
saved and appears on my blog but I get the following error: (I also get
this error when trying to view the details for an entry.)
----
ProgrammingError at /admin/blog/entry/7/
(1146, "Table 'django_.blog_entry_tags' doesn't exist")
Request Method: GET
Request URL: http://binarymanipulations.com:8157/admin/blog/entry/7/
Exception Type: ProgrammingError
Exception Value: (1146, "Table 'django_.blog_entry_tags' doesn't exist")
Exception Location:
/usr/local/lib/python2.4/site-packages/MySQLdb/connections.py in
defaulterrorhandler, line 35
Python Executable: /usr/local/bin/python
Python Version: 2.4.3
[snipped]
----
My blog/models.py is below (and here http://dpaste.com/hold/16673/) :
----
from django.db import models
import datetime
# Create your models here.
class Tag(models.Model):
slug = models.SlugField(
prepopulate_from=("name",),
help_text='Automatically prepopulated from name',
)
name = models.CharField(maxlength=30)
description = models.TextField(
help_text='Short summary of this tag'
)
def __str__(self):
return self.name
def get_absolute_url(self):
return "/blog/tag/%s/" % self.slug
class Admin:
list_display = ('slug', 'name',)
search_fields = ('name', 'description',)
class Entry(models.Model):
title = models.CharField(maxlength=255, core=True,
unique_for_date="pub_date")
pub_date = models.DateTimeField(core=True)
slug = models.SlugField(maxlength=30, prepopulate_from= ['title'])
body = models.TextField(core=True)
tags = models.ManyToManyField(Tag,
filter_interface=models.HORIZONTAL)
class Admin:
fields = (
(None, {'fields': ('slug', 'title', 'tags',
'pub_date', 'body',)}),
)
def __str__(self):
return self.title
def get_absolute_url(self):
return "/blog/%s/%s/" %
(self.pub_date.strftime("%Y/%m/%d").lower(), self.slug)
----
I have ran python manage.py syncdb. I really don't know what is going on
but I have a slight idea it might have something to do with the Entry
tags field. It seems like django wants to see a blog_entry_tags table in
the database but it isn't there. Maybe a problem with the ManyToManyField?
Thanks,
Evan
ManyToManyField keeps track of the relations in a 3 column third table
like: id | entry_id | tag_id, usually called
appname_model1_model2(s), or blog_entry_tags.