#23415: OneToField reference to default 'id' instead of actual primary key
----------------------------+------------------------------------
Reporter: sky-chen | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
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
----------------------------+------------------------------------
Changes (by Markush2010):
* cc: Markush2010 (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
Some details that are causing the problem: The migration `0001` for
`deg.Client` has a `CreateModel` operation that adds the Client model to
Django's migration state. Unfortunately the operation doesn't contain any
fields:
{{{#!python
migrations.CreateModel(
name='Client',
fields=[],
options={
'managed': False,
'db_table': 'Clients',
'verbose_name': 'Client',
},
bases=(models.Model,),
),
}}}
Therefore Django doesn't know about the explicit primary key field and
cannot point the FK their but rather relies on some defaults. The problem
is in
`django.db.migrations.autodetector.MigrationAutodetector.generate_created_unmanaged()`
and `.generate_created_proxies()` and which makes proxy models also be
affected by that bug.
Right now this problem can be worked around with the following steps:
1. remove existing migrations for `dep` and `pubsite`
2. change `managed = False` to `managed = True`
3. run `manage.py makemigrations dep pubsite`
4. change `managed = True` back to `managed = False`
5. in `dep.migrations.0001_initial` add `'managed': False` as a new option
to the `options` argument of the `CreateModel` operation.
--
Ticket URL: <https://code.djangoproject.com/ticket/23415#comment:1>
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/066.ef748649959c5922b0f43c1f4da7ace8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.