#36183: Model o2o inheritance with abstract models does not "evaluate" a lazy
relationship
-------------------------------------+-------------------------------------
Reporter: BeryCZ | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by BeryCZ):
Hello Natalia, thanks for your response, but I think you either
misunderstood or I'm missing something that's not clear from your answer.
Based on the docs https://docs.djangoproject.com/en/5.1/topics/db/models
/#multi-table-inheritance I can override the primary key on `ArticlePage`
so instead of `page_ptr` I can have just `page`. So that's what I'm doing,
it works when I put it in `ArticlePage` model, but not when I put it the
`AbstractPageType`.
I've just asked on discord and klove said it should be ok to name the pk
`page`.
So I even tried to remove my custom pk field and checked
`ArticlePage.page` and `article_page_object.page` and both raise
AttributeError, so by default `page` is not there.
My use case is - I want to have the "parent" model `Page` from which I can
MTI "submodels" like Article, Category, Product, Reference, whatever. The
`Page` model will then be used for references in other models (galeries,
urls, tree-maps, ...).
So, am I missing something, or is this a bug? I'm not saying it's an easy-
to-fix bug :) but I honestly think it is a bug.
I'm not even sure where the lazy load of `to` relationship is, or why it
doesn't work in abstract models, otherwise I would try to fix it and PR.
Thank you,
Bery
--
Ticket URL: <https://code.djangoproject.com/ticket/36183#comment:2>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070194fb5b7b27-4e690864-c924-4d1c-904f-f5cd89fcbdc0-000000%40eu-central-1.amazonses.com.