4

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()
Modelesq
  • 5,192
  • 20
  • 61
  • 88
  • 3
    i think your answer is [here](http://stackoverflow.com/questions/3989717/django-adding-a-manytomany-field-table-to-existing-schema-related-name-error) basically syncdb turns an M2M field into a bridge table, as your table was already created syncdb wont make the bridge table your app expects hence the error, solution use South or manually make the table as syncdb would – T I Jul 03 '12 at 21:12
  • 1
    @TomIngram: might as well make that comment an answer, since it *is* the answer. – Chris Pratt Jul 03 '12 at 21:18
  • Thank you for your help. I'm assuming you could `DROP` the existing table and just recreate it with the new column? – Modelesq Jul 03 '12 at 21:33

2 Answers2

5

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
badp
  • 11,409
  • 3
  • 61
  • 89
Greg
  • 9,963
  • 5
  • 43
  • 46
0

A "No such table" means that your database doesn't contain a table with the name you wrote.

Check if the name is written exactly as in the database (is better if you maintain the case). If the name is ok, set the name of the database schema in which you created the table, preceding the name of the table, such as my_schema.my_table.

Igor Rodriguez
  • 1,196
  • 11
  • 16