i would never try to fight my database and django like that. I would add a separate uuid field
On Fri, Nov 10, 2017 at 10:54 PM, Liuyang Wan <tsf...@gmail.com> wrote: > Let's say in my Django project I have two models A and B. > > class A(models.Model): > something... > > class B(models.Model): > a = models.ForeignKey(A) > > Later on I decided to use uuid as the primary key value. so I update the > models: > > import uuid > > class A(models.Model): > id = models.UUIDField( > db_index=True, > default=uuid.uuid4, > editable=False > ) > > > class B(models.Model): > id = models.UUIDField( > db_index=True, > default=uuid.uuid4, > editable=False > ) > > a = models.ForeignKey(A) > > Now if I make a migration, Django will NOT pick the changes with the > foreign key, i.e the type of fk *B.a* needs to be updated to uuid as > well, not integer anymore. > > Is this a bug with current version of Django? What is the best practice > for handling such case? > > Thanks, > Liuyang > > > -- > 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+unsubscr...@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/a68ab6ce-a1c1-42a8-b3d8-82a30edb1079%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/a68ab6ce-a1c1-42a8-b3d8-82a30edb1079%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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+unsubscr...@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/CAAuoY6NBRyK%2Btfxpcv6XToXwWXW%3DTp5AAutEmmAh%2BD6vszZ%2Biw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.