[Django] #33510: dumpdata command misses models sublcassed from other non-abstract models

17 views
Skip to first unread message

Django

unread,
Feb 10, 2022, 2:59:01 PM2/10/22
to django-...@googlegroups.com
#33510: dumpdata command misses models sublcassed from other non-abstract models
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
robinharms |
Type: Bug | Status: new
Component: Core | Version: 3.2
(Management commands) |
Severity: Normal | Keywords: dumpdata
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Essentially the same issue that was fixed in Django 2 has resurfaced in 3
so I'll only write a short description.

{{{

class Person(models.Model):
some_field...
...


class Doctor(Person):
doctor_field...
...


my_doctor = Doctor.objects.create(...)

}}}

Running manage dumpdata will cause the export to be broken. The
"my_doctor" instance will be exported without the pointer to the person-
object it will models will be within the export, but without the linking
pointer value. (Probably called something like person_ptr) However if
--natural-primary is included, the key will be there.

However, regardless of method the needed linked data within the person
table is omitted, so running import data on a site with subclassed models
like this will ''never'' work.

This bug seems to be present in 3.0 and onward.

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

Django

unread,
Feb 11, 2022, 12:46:59 AM2/11/22
to django-...@googlegroups.com
#33510: dumpdata misses models subclassed from other non-abstract models
-------------------------------------+-------------------------------------
Reporter: Robin Harms | Owner: nobody
Oredsson |
Type: Bug | Status: closed
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution: invalid
Keywords: dumpdata | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: new => closed
* resolution: => invalid


Comment:

Thanks for the report.

> However, regardless of method the needed linked data within the person
table is omitted, so running import data on a site with subclassed models
like this will never work.

Have you tried to import dumped data? It works for me in both cases, i.e.
with and without using `--natural-primary`. `person_ptr` is unnecessary
because it's a `OneToOneField()` which is also a `Doctor`'s primary key,
see [https://docs.djangoproject.com/en/4.0/topics/db/models/#multi-table-
inheritance docs].

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

Django

unread,
Feb 15, 2022, 5:33:34 AM2/15/22
to django-...@googlegroups.com
#33510: dumpdata misses models subclassed from other non-abstract models
-------------------------------------+-------------------------------------

Reporter: Robin Harms | Owner: nobody
Oredsson |
Type: Bug | Status: closed
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution: invalid
Keywords: dumpdata | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Robin Harms Oredsson):

Hi, sorry about this. You're right - the reason I have this problem is
that the superclass has a custom manager that causes polymorphic
behaviour, so the 1-1 relation becomes corrupt. So not a problem with
Django.

I thought those custom managers were disabled during exporting though?

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

Reply all
Reply to author
Forward
0 new messages