In Django < 1.7, if settings.AUTH_USER_MODEL is defined, the sender is expected to be the actual instance, not a string. This Closes rossp/django-helpdesk#295 by checking for django version < 1.7.

This commit is contained in:
Alex Seeholzer 2015-02-11 12:23:59 +01:00
parent a87e1355ee
commit 9665361bb1

View File

@ -1041,6 +1041,10 @@ def create_usersettings(sender, instance, created, **kwargs):
UserSettings.objects.create(user=instance, settings=DEFAULT_USER_SETTINGS)
try:
# Connecting via settings.AUTH_USER_MODEL (string) fails in Django < 1.7. We need the actual model there.
# https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#referencing-the-user-model
if django.VERSION < (1, 7):
raise ValueError
models.signals.post_save.connect(create_usersettings, sender=settings.AUTH_USER_MODEL)
except:
signal_user = get_user_model()