Questions tagged [dumpdata]

`django-admin.py dumpdata` is a command you could use to output to standard output all data in the database associated with the named application(s) in a Django powered website.

To see detailed information about django-admin.py dumpdata see the Django docs.

52 questions
181
votes
13 answers

Django dump data for a single model?

Can I perform a dumpdata in Django on just a single model, rather than the whole app, and if so, how? For an app it would be: python manage.py dumpdata myapp However, I want some specific model, such as "myapp.mymodel" to be dumped. The reason…
nategood
  • 11,807
  • 4
  • 36
  • 44
37
votes
4 answers

In Django, getting a "Error: Unable to serialize database" when trying to dump data?

I'm getting an error when I'm trying to dump data to a JSON fixture in Djanog 1.2.1 on my live server. On the live server it's running MySQL Server version 5.0.77 and I imported a lot of data to my tables using the phpMyAdmin interface. The website…
littlejim84
  • 9,071
  • 15
  • 54
  • 77
29
votes
13 answers

Django dumpdata UTF-8 (Unicode)

Is there a easy way to dump UTF-8 data from a database? I know this command: manage.py dumpdata > mydata.json But the data I got in the file mydata.json, Unicode data looks like: "name":…
icn
  • 17,126
  • 39
  • 105
  • 141
22
votes
5 answers

How to use call_command with dumpdata command to save json to file

I am trying to use the call_command method to call the dumpdata command. Manually, I use it as follows to save the data to a file. python manage.py dumpdata appname_one appname_two > /path/to/save/file.json and it saves the json file. Now, I am in…
Amyth
  • 32,527
  • 26
  • 93
  • 135
17
votes
2 answers

Use Django dumpdata to dump a subset of overall data?

I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing? I'm using MySQL and Django 1.0.
thebossman
  • 4,598
  • 11
  • 34
  • 45
15
votes
1 answer

Django's "dumpdata" or Postgres' "pg_dump"?

I'm unsure as to whether this question should be posted in the Database Administrators' section or here, so please advise if I got it wrong. I have a Django-based website which doesn't change much. I use python manage.py dumpdata --all --indent=2 >…
Keenan Lawrence
  • 1,446
  • 10
  • 16
12
votes
1 answer

Django backup strategy with dumpdata and migrations

As in this question, I set up a dumpdata-based backup system for my database. The setup is akin to running a cron script that calls dumpdata and moves the backup to a remote server, with the aim of simply using loaddata to recover the database.…
Felipe
  • 3,003
  • 2
  • 26
  • 44
11
votes
1 answer

Dumpdata with unmanaged models

I'm trying to dump my database (sqlite3) to a json file for a fixture, but I have an unmanaged model which is causing a no such table error (obviously!) so how do you dumpdata with these kind of models in the db? Model: from django.db import…
markwalker_
  • 12,078
  • 7
  • 62
  • 99
10
votes
2 answers

Duplicate key issue when loading back.json file PostgreSQL

I have a PostgreSQL database that where I performed python manage.py dumpdata to backup the data into a json file. I created a new PostgreSQL database, performed a migrate, and everything worked like clockwork. When I tried to load the backup.json…
TJB
  • 3,706
  • 9
  • 51
  • 102
8
votes
3 answers

Django: loaddata not working

I generated a fixture: python manage.py dumpdata --all > ./mydump.json I emptied all my databases using: python manage.py sqlflush | psql mydatabase -U mydbuser But when i try to use loaddata: python manage.py loaddata ./mydump.json I'm recieving…
Adrian Lopez
  • 2,601
  • 5
  • 31
  • 48
6
votes
1 answer

export data from Django database

how to copy records from one database to another django ? I tried for the first database python manage.py dumpdata material - indent = 1 material is the directory database after ? material.json ? do I copy this file somewhere? in the second…
user1788104
  • 81
  • 1
  • 5
5
votes
1 answer

Django migrate from MySQL to Postgres

I recently decided that I want to switch from MySQL to Postgres because of a few problems I have been having which should never be a problem on Postgres. However I cannot seem to find a nice way to migrate I have taken a look at py-mysql2pgsql…
Sam Buckingham
  • 1,771
  • 2
  • 13
  • 16
5
votes
2 answers

Django : Generic Foreign key dumpdata: Can't resolve dependencies

I use Generic Foreign keys to relate different profiles with my Users model which is inherited from auth.User. I'm not able to do dumpdata though with the --natural option passed. It says, Error: Can't resolve dependencies for…
Babu
  • 2,548
  • 3
  • 30
  • 47
4
votes
3 answers

python manage.py dumpdata Unable to serialize database

I am trying to run the command python manage.py dumpdata > data.json However, I receive such a traceback: CommandError: Unable to serialize database: 'charmap' codec can't encode characters in position 1-4: character maps to Exception…
illymarev
  • 237
  • 2
  • 13
4
votes
1 answer

django-admin.py dumpdata to SQL statements

I'm trying to dump my data to SQL statements. the django-admin.py dumpdata provides only json,xml,yaml. so: does someone know a good way to do it?! I tried that: def sqldumper(model): result = "" units = model.objects.all().values() for unit in…
nivniv
  • 3,421
  • 5
  • 33
  • 40
1
2 3 4