[Django]-Django admin throws error after installing tastypie?

5👍

Make sure you added tastypie to INSTALLED_APPS and launched manage.py syncdb to create tastypie tables into the database (there are 2: tastypie_apiaccess & tastypie_apikey).

👤manji

6👍

OK, I had a similar issue, but it wasn’t solved by the solution given by @manji.

The problem has to do with Django and the use of the create_api_key signal. syncdb will create the user first before tastypie is able to create its tables.

The solution that worked for me was:

  1. Wrap your signal in your model with a try/except statement like:

    try:
        models.signals.post_save.connect(create_api_key, sender=User)
    except Exception, e:
        pass
    
  2. Run ./manage.py syncdb --migrate

  3. Run ./manage.py backfill_api_keys

Here’s the issue on GitHub for your reference: https://github.com/toastdriven/django-tastypie/issues/195

Leave a comment