3👍
I am trying to do the same exact thing right now, but I am running into a problem with resolving dependencies basically the same as ticket 16317. But enough about me…
Troubleshooting this led me to find a link for django-smuggler which allows you to create dumps and load data from the admin interface.
It looks promising for any data transfer needed or to use as a backup utility.
39👍
First, execute
manage.py dumpdata > out.json
then change your DB config, migrate (or syncdb) and finally
echo "delete from auth_permission; delete from django_content_type;" | python manage.py dbshell
(If you have Django older than 1.11, you need to use
echo "delete from django_content_type;" | manage.py dbshell
)
Then load the JSON file:
manage.py loaddata out.json
(as of 2013 django_contenttype
is replaced with django_content_type
)
- [Django]-Raw SQL queries in Django views
- [Django]-How to configure Django on OpenShift?
- [Django]-Show undefined variable errors in Django templates?
2👍
If you get errors when loading the data, first dump it like this:
python manage.py dumpdata --exclude auth.permission --exclude contenttypes > datadump.json
as described here:
- [Django]-How to show a message to a django admin after saving a model?
- [Django]-How can I find the union of two Django querysets?
- [Django]-Unique validation on nested serializer on Django Rest Framework
0👍
I was in this same situation and was having trouble loading the data into the new postgresql database due to key constraint errors. What worked for me was to rename my ‘default’ sqlite database to ‘sqlite’, add my postgresql database connection as ‘default’, do the data export like this:
python manage.py dumpdata --database sqlite --natural-foreign --natural-primary > sqlite-dump.json
Then load the data into the new database like this:
python manage.py loaddata sqlite-dump.json
(This is with Django 2.2.)
- [Django]-Write only, read only fields in django rest framework
- [Django]-Modify value of a Django form field during clean()
- [Django]-Can I use MySQL on Django(dev 1.6.x) with Python3.x?