I may found a bug

36 views
Skip to first unread message

otloal

unread,
Oct 21, 2017, 10:12:50 PM10/21/17
to Django users
Hi, I think I may discovered a bug in django, but I’m not sure
[03:19am] The bug is this: 1. You make a ManyToManyField related the same model in wich you are creating the field
[03:20am] Example:
[03:21am] 
class WhatEver(models.Model): 
field = models.ManyToManyField(‘Whatever’, related_name=‘related_rel_name’)
[03:22am] this creates an appname_whatever table and and an appname_whatever_fields table in the database that contains to fields: from_whatever_id and whatever_id
[03:24am] Obviously takes the word from_ in the first field to difference from the second field
[03:24am] The bug:
[03:24am] If I change the field in the model to b.e 
field = models.ManyToManyField(AnotherObject, related_name=‘related_rel_name’)
 
[03:26am] and I make migrations and migrate, the db table field whatever_id changes to anotherobject_id, but the field from_whatever_id remains intact
[03:28am] when you use the relation in your proyect you get an error like "theres no appname_whatever_fields.whatever_id"
[03:28am] I had to rename manually from_whatever_id to whatever_id
[03:28am] Check it, please

James Schneider

unread,
Oct 23, 2017, 5:06:12 AM10/23/17
to django...@googlegroups.com
I'm pretty lost in the generalizations you are using. If I follow it right, though, it sounds like the DB structure is updated properly. 

I have no idea what appname_whatever_fields.whatever_id would even refer to in a real example, but it doesn't appear to be the relation you are referring to. I also have no idea what you renamed. I'm assuming the DB table column but that doesn't make any sense.

-James
Reply all
Reply to author
Forward
0 new messages