{{{
class Act(models.Model):
....
class Form(Act):
...
class Diagnosis(Act):
form = models.ForeignKey(Form)
}}}
...and this admin.py:
{{{
class DiagnosisInline(admin.TabularInline):
model = Diagnosis
...
class FormAdmin(admin.ModelAdmin):
....
inlines = [DiagnosisInline]
admin.site.register(Form, FormAdmin)
}}}
This triggers 'admin.E202':
{{{
<class 'nm.admin.DiagnosisInline'>: (admin.E202) 'nm.Diagnosis' has more
than one ForeignKey to 'nm.Form'
}}}
Without looking into the source for this system check, I guess, that it
counts all possible references, that lead to the admin class, the inline
is included in.
And it counts two, from which one is right (Form) and one is wrong (Act),
because it's already it's own superclass reference.
Am I right?
--
Ticket URL: <https://code.djangoproject.com/ticket/24867>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
There's no need to have the foreign key on `Diagnosis` as that model has
an automatically created `OneToOneField` to `Form` because your models use
[https://docs.djangoproject.com/en/stable/topics/db/models/#multi-table-
inheritance multi-table inheritance].
--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:1>
Comment (by TorstenRottmann):
Well, that doesn't work. The inlines should be the {{{Diagnosis}}}, that
point to a {{{Form}}} – and I simply can't manage that to work.
How is that done?
--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:2>
* status: closed => new
* resolution: invalid =>
--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:3>
* status: new => closed
* resolution: => invalid
Comment:
Maybe what you meant to do is make Act an
[https://docs.djangoproject.com/en/stable/topics/db/models/#abstract-base-
classes abstract base model]. In that case, your original code should work
fine.
For future reference, "is it a bug" type questions should be directed to
our support channels at TicketClosingReasons/UseSupportChannels. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:4>