toastdriven/django-tastypie — pull request #887 by mattdeboard (2013-04-01 19:03:10+00:00)
Title: Added optional setting to force the 'ApiKey' model to be an abstract base class.

If set to true, ``TASTYPIE_ABSTRACT_APIKEY`` will set ``abstract = True`` on ``models.ApiKey._meta``.

This patch is intended to address an issue I have run into where we have multiple databases set up, each of which contains an instance of the ``auth_user`` table created by ``django.contrib.auth.models.User``. I am not using ``ApiKeyAuthentication`` anywhere in my application. However, because there's a foreign key relation with the ``reverse`` option set, all of my user instances have an ``api_key`` property. When trying to delete a user, Python complains there is no database called ``tastypie_apikey``.

To get around this I *could* write the SQL to add this table I'm not using to every database. Instead I borrowed the approach used by [django-rest-framework](https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/authtoken/models.py) to solve a similar problem.

I updated the docs and the ``AUTHORS`` file but adding a test for this case isn't something I felt comfortable doing. I will be glad to work with a core contrib if they can guide me on how to add a test case for a multi-database setup to demonstrate the problem.