[Django] #28332: Cannot get diamond multiple inheritance example to work

10 views
Skip to first unread message

Django

unread,
Jun 21, 2017, 10:24:39 PM6/21/17
to django-...@googlegroups.com
#28332: Cannot get diamond multiple inheritance example to work
-----------------------------------------+------------------------
Reporter: Luc Saffre | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I need help with getting to test some code which is AFAICS equivalent to
the second example (Piece, Book, Article, BookReview) of the
[https://docs.djangoproject.com/en/1.11/topics/db/models/#multiple-
inheritance Multiple inheritance] section of the Models topic guide.

To reproduce my problem, please download the following files from
[https://github.com/lino-framework/book/tree/master/docs/tested/diamond
this directory] of my repository:

- [https://github.com/lino-
framework/book/blob/master/docs/tested/diamond/main/models.py
main/models.py]
- `main/__init__.py`
- `manage.py`
- `settings.py`

and then run:

{{{
$ python manage.py check
}}}

The output is:

{{{
SystemCheckError: System check identified some issues:

ERRORS:
main.PizzeriaBar: (models.E005) The field 'restaurant_ptr' from parent
model 'main.bar' clashes with the field 'restaurant_ptr' from parent model
'main.pizzeria'.
}}}

The failure works in Django versions 1.11.2, 1.10.7, 1.9.13 (and maybe
earlier as well).

I could not find any relevant difference between my code and the example
in the documentation.

Any hints?

--
Ticket URL: <https://code.djangoproject.com/ticket/28332>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 22, 2017, 8:54:06 AM6/22/17
to django-...@googlegroups.com
#28332: Diamond multiple inheritance example in docs gives a clashing field check
error
-------------------------------+------------------------------------

Reporter: Luc Saffre | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.11
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 Tim Graham):

* type: Uncategorized => Bug
* component: Uncategorized => Documentation
* stage: Unreviewed => Accepted


Comment:

It looks like the example in the documentation (added in #22442) never
worked. I tested back to Django 1.7 and the check error is the same. If it
cannot be fixed, perhaps it should be removed.

--
Ticket URL: <https://code.djangoproject.com/ticket/28332#comment:1>

Django

unread,
Aug 17, 2017, 2:36:03 PM8/17/17
to django-...@googlegroups.com
#28332: Diamond multiple inheritance example in docs gives a clashing field check
error
-------------------------------------+-------------------------------------
Reporter: Luc Saffre | Owner: Jeremy
| Satterfield
Type: Bug | Status: assigned

Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jeremy Satterfield):

* owner: nobody => Jeremy Satterfield
* status: new => assigned
* has_patch: 0 => 1


Comment:

The `PizzeriaBar` model is inheriting the `restaurant_ptr` field from both
`Pizzeria` and `Bar`, so you need to specify the parent link field on at
least one of them, per
https://docs.djangoproject.com/en/dev/topics/db/models/#specifying-the-
parent-link-field. This gets a little complicated if you are creating this
child model and overriding these field names at a later date than the
parent since you are changing the field name, it is going to require using
the `db_column` arg on the field or more complex migrations.

This seems to me to have a lot of caveats to be provided as an example in
the docs; however, here is a PR that updates the existing example to be
working.

--
Ticket URL: <https://code.djangoproject.com/ticket/28332#comment:2>

Django

unread,
Aug 22, 2017, 8:42:42 PM8/22/17
to django-...@googlegroups.com
#28332: Diamond multiple inheritance example in docs gives a clashing field check
error
-------------------------------------+-------------------------------------
Reporter: Luc Saffre | Owner: Jeremy
| Satterfield
Type: Bug | Status: assigned
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Luc Saffre):

I confirm that this fixes the problem. Yes, diamond inheritance has more
problems than this (see [http://luc.lino-framework.org/blog/2017/0823.html
my blog] for an example) and I currently avoid it in my projects. But
still it is a feature for Django and I recommend to not remove if from the
docs (but to rather write more about it).

--
Ticket URL: <https://code.djangoproject.com/ticket/28332#comment:3>

Django

unread,
Sep 2, 2017, 2:33:19 PM9/2/17
to django-...@googlegroups.com
#28332: Diamond multiple inheritance example in docs gives a clashing field check
error
-------------------------------------+-------------------------------------
Reporter: Luc Saffre | Owner: Jeremy
| Satterfield
Type: Bug | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"473ab4610ef90be05f09127aa37cd20bcda5875e" 473ab461]:
{{{
#!CommitTicketReference repository=""
revision="473ab4610ef90be05f09127aa37cd20bcda5875e"
Fixed #28332 -- Fixed diamond inheritence example in docs.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28332#comment:4>

Django

unread,
Sep 2, 2017, 2:33:37 PM9/2/17
to django-...@googlegroups.com
#28332: Diamond multiple inheritance example in docs gives a clashing field check
error
-------------------------------------+-------------------------------------
Reporter: Luc Saffre | Owner: Jeremy
| Satterfield
Type: Bug | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e921e983876b62f5b8f405e0b8afcdcc1f53d8bb" e921e98]:
{{{
#!CommitTicketReference repository=""
revision="e921e983876b62f5b8f405e0b8afcdcc1f53d8bb"
[1.11.x] Fixed #28332 -- Fixed diamond inheritence example in docs.

Backport of 473ab4610ef90be05f09127aa37cd20bcda5875e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28332#comment:5>

Reply all
Reply to author
Forward
0 new messages