Modify ↓
Ticket #326 (closed defect: fixed)
problems with orm and multi-table inheritance
| Reported by: | bas@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.7 |
| Component: | migrations | Version: | 0.6.2 |
| Keywords: | inheritance orm | Cc: |
Description
Hi,
I'm trying to do some data migration using model class (for example, Restaurant) that inherits from other non-abstract model (for example, Place) in a multi-table inheritance mode. In South migration file I do:
restaurants = orm.Restaurant.filter(field1='blabla')
If field1 belongs to Restaurant model then it works just fine. But if field1 belongs to Place then that line fails with:
django.core.exceptions.FieldError: Cannot resolve keyword 'field1' into field. Choices are: ...Restaurant only fields listed here...
It works perfectly in real Django orm world.
Let me know if you need me to attach a real example.
Thank you.
Attachments
Change History
comment:2 Changed 3 years ago by andrew
- Status changed from new to assigned
- Milestone set to 0.7
Yes, I think this is another slight imperfection of the ORM. I'll schedule it for fixing in the upcoming 0.7.
comment:3 Changed 3 years ago by andrew
- Status changed from assigned to closed
- Resolution set to fixed
This has been fixed along with #182 in [237ca3bb6d5d].
Note: See
TracTickets for help on using
tickets.

I found a workaround,
If parent_link in Restaurant (OneToOneField? link to base Place model) is defined as:
and you want to filter by Place's field1 just do:
It works to any level of inheritance.
Anyway, it would be good to replicate how Django handles base model fields filtering in South.