lukaszb/django-guardian — pull request #94 by derks (2012-11-03 08:14:53+00:00)
Title: Django 1.5+ Fixes (Resolves Issues #92, #93)

Django 1.5+ now supports custom User model classes. This is outlined here:

* https://docs.djangoproject.com/en/dev/topics/auth/#auth-custom-user

Guardian currently does not support this due to its explicit use of django.contrib.auth.models.User. I chose to resolve this by making all imports from django.contrib.auth.models change over to guardian.models. I figured if upstream made this change for User, it may make similar changes to Group, Permission, AnonymousUser, etc. Referencing all contrib.auth.models import from guardian.models would make it easy to make such changes in the future.

The primary change is in guardian.models where I attempted to import and utilize get_user_model(), and if it fails fall back to just importing the User model. Subsequently, all references throughout the code had to be updated (including tests). Additionally during these changes an incompatiblity cropped up regarding SECRET_KEY not being setting in the settings.py (Issue #93). I resolved this by setting it to: 'CHANGE_THIS_TO_SOMETHING_UNIQUE_AND_SECURE'. The only two locations for the settings.py that needed to be changed was in testsettings.py, and example_project/settings.py which effectively don't actually need to be 'secure', but need the setting set.

I have tested these changes against Django 1.4.2, 1.5dev, and 1.6dev. All tests pass successfully. Please let me know if you have any questions about these changes.