﻿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	Assigning ForeignKey fields in migrations	Odero	nobody	"Trying to create the migration below which is failing. It seems like the same issue discussed and resolved here https://code.djangoproject.com/ticket/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
    )
    invoice.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.
}}}
"	Bug	new	Uncategorized	1.10	Normal		migrations, foreignkey		Unreviewed	0	0	0	0	0	0
