Monday, October 23, 2017

Re: I may found a bug



On Oct 21, 2017 7:12 PM, "otloal" <aoterolorenzo@gmail.com> wrote:
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

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

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVdq0AEdWm_DYBCLA%3DpqJW7N1Wk9UyZM57AwEF%3D4kr_Uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment