Change GFK to FK

45 views
Skip to first unread message

carlos

unread,
Sep 28, 2014, 6:15:22 PM9/28/14
to django...@googlegroups.com
Hi, is posible to change GenericForeingnKey to ForeignKey without losing data?

any link to explain the trick?

I have an old application with GFK but now I want to FK moment but I will not lose data

this is example my models old and below the new models


Cheers    

Tom Christie

unread,
Sep 29, 2014, 8:23:36 AM9/29/14
to django...@googlegroups.com
You'll probably want to take this approach:

* Create a schema migration, adding the FK.
* Create a data migration, populating the FK data.
* Create a schema migration, removing the GFK.

carlos

unread,
Sep 29, 2014, 3:59:13 PM9/29/14
to django...@googlegroups.com
Hi, ok my questions is how to create a data migration, populating the FK data??.
 my old data no have fk only content_type and object_id for my relations with
my class ModelMain,
 if fk = object_id?? or content_type?

thank

--
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...@googlegroups.com.
To post to this group, send email to django...@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/3730a43f-b926-48d4-be5f-5bcfa2914220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages