One, from that error message alone I can't figure out what is happening and why when you run tests, so I can't help there.
But two: you don't have a ManyToManyField, you have TWO ManyToManyFields. If you define a many to many field on one model, than it's automatically also defined on the other (if you only have the one on Pizza, then you can do topping.pizza_set.all() from the other side.On Fri, Dec 4, 2015 at 9:54 AM, filias <filipa.andrade@gmail.com> wrote:
Hi,--I have recently upgraded to sjango 1.8 and I have 2 models with a bi-directional ManyToMany field. It looks like thisclass Pizza(Model):available_toppings = ManyToManyField('Topping')class Topping(Model):all_pizzas = ManyToManyField(Pizza, through=Pizza.available_stoppings.through, verbose_name='available pizzas')Everything was fine in django 1.7 but right now when running tests, specifically when creating the test database, I get this exception:self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7fd24fca4b00>def execute(self, query, params=None):if params is None:> return Database.Cursor.execute(self, query)E OperationalError: table "products_pizza_available_toppings" already existsSo it looks like the creation of the test database is trying to re-create the intermediate table for the ManyToMany.I do not get any exception when running my site.Does anyone know how can I fix this?Thank you in advance
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4b8bb3c4-c0bd-4315-9cb6-004db2fa2355%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFAGLK2HoLREAMCL8cFP%3D1raEotF_rD%2Bym-bBVuCDaQd6PKGtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment