-
-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dumpdata --natural
management command missing parent fields to restore polymorphic child models
#175
Comments
This is affecting me too. Is there any workaround? It is also evident when using --natural-foreign |
Workaround for me was to
Granted, this won't work if you want to do it in code, but I just wanted some fixtures to use in tests. |
I have this issue too (latest version of polymorphic + latest version of Django 1.8) The above fix isn't working for me - changing the base class to |
+1 |
I think you use Windows as me. Django-Polymorphic has special hack for this case in polymorphic/base.py:
But it doesn't work on Windows because it has backslashes instead of slashes in path. The correct way will be replace @chrisglass If it's not difficult please fix this bug. |
Still fails when |
Off-topic: As of django 1.11, there is no There is: |
The other thing is as of django-polymorphic 1.2, django.1.11.3 If I do a dump-data on a parent model, I get all the data, except the Also, |
When using If I'm using But if I just hook into Hope this helps. |
This is only with fixtures. By the way. If I create models on the fly through python or through the normal website, relationships are correctly created and show fine. |
Here's the good news: I do get the The bad news is loaddata doesn't actually help populate the relation. For instance, assume the I'll get a dump with "polymorphic_ctype": [
"ask",
"question"
], (yay). But upon
Any ideas @vdboor ? |
Just wanted to call out a related issue for anyone in the future that runs into it. The dumpdata hack that Polymorphic uses explicitly looks at |
Still having this issue in 2020. Is there any fix for that? I've published a question in StackOverflow and nothing. |
Hitting this issue when calling the management command through from django.core.management import call_command
call_command("dumpdata", "my_app", "-o", path) IMO the previous approach (i.e. providing a specific |
My project settings (my_django_project):
...
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polymorphic',
'my_app',
)
...
My application models (my_app):
The issue:
In the django admin, if i created two row of an
ArtProject
andResearchProject
.Then, i deleted everything, and try to restore the database with "dumpdata/loaddata" management command. The json file is clear missing some field to refer to the parent object. Like
topic
field fromProject
.Also, the json file can not be restored because of a missing pointer
project_ptr_id
, Which breaks the restoration later with the commandloaddata
referenced_table_name, referenced_column_name)) django.db.utils.IntegrityError: Problem installing fixtures: The row in table 'my_app_artproject' with primary key '1' has an invalid foreign key: my_app_artproject.project_ptr_id contains a value '1' that does not have a corresponding value in my_app_project.id.
My environment :
$ pip freeze
The text was updated successfully, but these errors were encountered: