#24264: foreign key constraint error migrating integer pk to CharField ----------------------------+------------------------------------- Reporter: timgraham | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.8alpha1 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+-------------------------------------
Comment (by MarkusH): This patch on stable/1.8.x (edbf6de7536f7a6c1e5df019a5e1947d2c9dadf8) fixes the problem for me, but is more a band-aid than a valid fix: {{{#!patch diff --git a/django/db/models/options.py b/django/db/models/options.py index fa97265..e64990d 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -687,7 +687,8 @@ class Options(object): for f in fields_with_relations: if not isinstance(f.rel.to, six.string_types): # Set options_instance -> field - related_objects_graph[f.rel.to._meta].append(f) + opts = f.rel.to._meta + related_objects_graph[opts.app_label, opts.object_name].append(f) for model in all_models: # Set the relation_tree using the internal __dict__. In this way @@ -695,7 +696,8 @@ class Options(object): # __dict__ takes precedence over a data descriptor (such as # @cached_property). This means that the _meta._relation_tree is # only called if related_objects is not in __dict__. - related_objects = related_objects_graph[model._meta] + opts = model._meta + related_objects = related_objects_graph[opts.app_label, opts.object_name] # If related_objects are empty, it makes sense to set # EMPTY_RELATION_TREE. This will avoid allocating multiple empty }}} -- Ticket URL: <https://code.djangoproject.com/ticket/24264#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.9cdbfbd4091b0ee59b7061f6b43dfe2f%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.