0

What would be the best approach to migrating or importing data from a very old Django app (0.97) to a relatively "modern" Django release (1.8)?

The application (if you can call it that) is little more than a series of models and some simple views. The users primarily accessed it via the admin UI (I know, I know). So in terms of code to convert, there's very little. I've updated the models.py to be 1.8-friendly, and I can easily spin up an empty instance of the app without difficulty.

However, I run into problems once I try to get the old data in the system. I thought I'd try dumpdata/loaddata, but didn't expect it to work (and it didn't). I get a number of errors along these lines:

django.db.utils.IntegrityError: Problem installing fixture 
'olddata.json': Could not load contenttypes.ContentType(pk=6):
 duplicate key value violates unique constraint
"django_content_type_app_label_5fd9156b761d2158_uniq"
DETAIL:  Key (app_label, model)=(contenttypes, contenttype)
already exists.

Before I dive into the depths of the export file, I want to be sure that I'm on the right track. Is there a better way to do this?

DrFyzziks
  • 61
  • 3
  • 1
    It looks like you're on the right track. You might want to post your models and a sample of olddata.json to give us a better idea. The error you're getting is saying that you're trying to violate a unique constraint. That implies either: 1. your new models have a unique constraint/primary key set wrong or 2. your olddata.json has duplicate PK/unique data somehow (bad export, etc). – wholevinski Mar 27 '18 at 18:11
  • 1
    try to export specific tables an import them to new database for example: python manage.py dumpdata app.table --indent 4 --format xml > fixtures/app_table.xml – Dimitris Kougioumtzis Mar 27 '18 at 18:12

1 Answers1

0

Thanks to both of you. It appears as though the json export from 0.97 was the problem. I did a full XML export and import, and only ran into a single error w/one record containing some XML-like content that caused the XML parser some trouble - easily fixed.

It appears as though 0.97 version of dumpdata outputs json that is not fully supported by Django 1.8.

DrFyzziks
  • 61
  • 3