Saturday, October 21, 2017

I may found a bug

Hi, I think I may discovered a bug in django, but I'm not sure
03:19amThe bug is this: 1. You make a ManyToManyField related the same model in wich you are creating the field
03:20amExample:
03:21am
class WhatEver(models.Model): 
field = models.ManyToManyField('Whatever', related_name='related_rel_name')
03:22amthis 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:24amObviously takes the word from_ in the first field to difference from the second field
03:24amThe bug:
03:24amIf I change the field in the model to b.e 
field = models.ManyToManyField(AnotherObject, related_name='related_rel_name')
 
03:26amand I make migrations and migrate, the db table field whatever_id changes to anotherobject_id, but the field from_whatever_id remains intact
03:28amwhen you use the relation in your proyect you get an error like "theres no appname_whatever_fields.whatever_id"
03:28amI had to rename manually from_whatever_id to whatever_id
03:28amCheck it, please

--
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/9ff8a220-457c-4801-a84c-8b783a8a0bed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment