mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 01:13:31 +01:00
Make sure custom user logic works with Django 1.4
Monkey Patch for Django 1.4 to allow new custom user model logic.
This commit is contained in:
parent
eef2a66f23
commit
1aed6c9a96
@ -0,0 +1 @@
|
||||
import monkey_patch # Patch User model for older versions of Django
|
15
helpdesk/monkey_patch.py
Normal file
15
helpdesk/monkey_patch.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
django-helpdesk - A Django powered ticket tracker for small enterprise.
|
||||
|
||||
(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details.
|
||||
|
||||
monkey_patch.py - Monkey Patch the User model for older versions of
|
||||
Django that don't support USERNAME_FIELD and get_username
|
||||
"""
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
if not hasattr(User, "USERNAME_FIELD"):
|
||||
User.add_to_class("USERNAME_FIELD", "username")
|
||||
if not hasattr(User, "get_username"):
|
||||
User.add_to_class("get_username", lambda self: getattr(self, self.USERNAME_FIELD))
|
Loading…
Reference in New Issue
Block a user