You forgot to actually modify/create the tables in database (manually, with South
or manage.py syncdb
).
Django database error on one to many relationship
Question
I created a data model in Django which has many to one relation (N topics to 1 user) like this:
from django.db import models from django.contrib.auth.models import User
# Create your models here.
class Topic(models.Model):
content = models.CharField(max_length=2000)
pub_date = models.DateTimeField('date published')
author = models.ForeignKey(User)
When I try to load the data model in the admin page, I get this error:
Exception Value:
no such column: talk_comment.author_id
Did I miss something in the data model?
Thanks.
Solution
OTHER TIPS
You can't modify the table with syncdb
. you need to use South Migrations
Its really very good and you can even revert back to previous migration in case of some problem
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow