django reset contenttypes mismatch
Question: Have deleted my database.

Have run SyncDb.

Trying to load from dump ..-python manage.py loaddata dump.json.

Get- "<1062 Duplicate entry '' for key.."

Have run "python manage.py reset contentypes"

But get-

    
    
     Error: Error: contenttypes couldn't be reset. Possible reasons:
      * The database isn't running or isn't configured correctly.
      * At least one of the database tables doesn't exist.
      * The SQL was invalid.
    Hint: Look at the output of 'django-admin.py sqlreset contenttypes'. That's the SQL this command wasn't able to run.
    The full error: (1217, 'Cannot delete or update a parent row: a foreign key constraint fails')
    

Have try to run:

> > > from django.core import management
>>>

>>> management.call_command("flush", verbosity=, interactive=False)

>>>

>>> management.call_command("totally reset", "contenttypes", verbosity=,
interactive=False)

>>>

>>> management.call_command("loaddata", "full_test_data.json", verbosity=)

But get- syntax error.

Have python 2.7. and Django 1.4

Any ideas?


Answer: Try setting `foreign_key_checks` false,

    
    
    DATABASES = {
        'default': {
            # ...         
            'OPTIONS': {
                "init_command": "SET foreign_key_checks = 0;",
            },
        }
    }
    

But you should definitely try to use the dumpdata command with the
[\--natural](https://docs.djangoproject.com/en/dev/ref/django-admin/#django-
admin-option---natural) option to make sure there's no hardcoded content types
in your fixtures.

