#27311: Assigning ForeignKey fields in migrations
-------------------------------+------------------------------------
Reporter: Odero | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords: migrations, foreignkey
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
I've created 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):
Payment = apps.get_model('finance', 'Payment')
Invoice = apps.get_model('finance', 'Invoice')
User = apps.get_model('accounts', 'User')
payment = Payment.objects.last()
invoice = Invoice(
client=payment.user),
status=5
)
invoice.save()
}}}
Also tried
{{{
invoice = Invoice(
client=User.objects.get(pk=payment.user.pk),
status=5
)
}}}
In both cases I get the error:
{{{
Cannot assign "<User: Some Client>": "Invoice.client" must be a "User"
instance.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27311>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.48db5a2fe4001eb04def5275c1aff490%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.