Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DatabaseError no such table with a ManyToManyField

So this is the situation: I'm adding a new column(presenters) to my Event table. I ran the alter table sql statements, ran python manage.py syncdb. I'm trying to be able to select many profiles and store them as presenters. Why is this happening?

Exception Type:     DatabaseError
Exception Value:    no such table: events_event_presenters

class Event(models.Model):
    title = models.CharField(max_length=200)
    presenters = models.ManyToManyField(Profile, null=True, blank=True) #new column
    sub_heading = models.CharField(max_length=200)
    description = models.TextField()
    date = models.DateTimeField()
like image 399
Modelesq Avatar asked Sep 14 '25 19:09

Modelesq


1 Answers

You've added a ManyToMany field to an existing table, which won't be detected by syncdb. Seems like a deficiency on django's part to me, but I guess it's minor. The easiest way to generate the table will be to run

./manage.py sql events

then find the definition for events_event_presenters and paste into your database shell, via

./manage.py dbshell
like image 171
Greg Avatar answered Sep 17 '25 09:09

Greg