﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27311	Support unpickled models (e.g. read from cache) in migrations	Odero	nobody	"Trying to create the migration below which is failing. It seems like the same issue discussed and resolved in #24282.

{{{
def generate_invoices(apps, schema_editor):
    A = apps.get_model('app1', 'A')
    B = apps.get_model('app1', 'B')
    User = apps.get_model('accounts', 'User')

    a = A.objects.last()

    b = B(
        client=a.user,
        status=5
    )
    b.save()
}}}

Also tried 


{{{
    b = B(
        client=User.objects.get(pk=a.user.pk),
        status=5
    )
}}}

In both cases I get the error:
{{{
Cannot assign ""<User: Some User>"": ""B.client"" must be a ""User"" instance.
}}}

Investigating the issue shows that it's due to the models being read from cache."	New feature	closed	Migrations	master	Normal	wontfix	migrations, foreignkey, cache	Markus Holtermann	Someday/Maybe	0	0	0	0	0	0
