manage.py dumpdata
is very convenient, I store fixture and other project related data in the project folder.
If two people work on the same project and want to merge the output of dumpdata, how ? And is there might be clash with primary keys ?
Asked
Active
Viewed 525 times
0

user3599803
- 6,435
- 17
- 69
- 130
-
Ideally you can do that (assuming there is no unique constraint violation). But rather than merging them, better would be load the data in your db, from one fixture, and create a fresh fixture from that. Remember, existing primary key will be overwritten by new fixture while uploading. You should be careful with that. – Rohit Jain Jul 31 '16 at 15:37
-
didn't understand. each one have its own db. And each can create a fixture of his 'foo' table. I want to merge them.. – user3599803 Jul 31 '16 at 16:04
-
Yes. You get the fixture from one db. Upload in second db. And then create fixture from the second db (that will be merged data). – Rohit Jain Jul 31 '16 at 16:06
-
So do you mean I will use general db exporting (dump, like mysqldump)? not using django for this purpose? (I won't call db dump a fixture) – user3599803 Jul 31 '16 at 16:31
-
`python manage.py dumpdata` from one django project, followed by: `python manage.py loaddata` onto second project. And then do `dumpdata` from second project. But be careful if you've `pk` in your fixture file. – Rohit Jain Jul 31 '16 at 16:33
-
May I ask why would you want that? Using ```dumpdata``` and ```loaddata``` will in this case will most likely result in problems with overlapping relations. In your place, to merge data from two databases (and in result work on one fixture for the whole project) I'd manually dump data from both DBs and come up with custom script to import them into DB. Django Extensions (https://django-extensions.readthedocs.io/en/latest/runscript.html) has a feature ```runscript``` allowing you to run script in Django context, which makes it easier to input some data into DB. – jacekbj Jul 31 '16 at 16:54