Luke Plant committed 8fdaee2

Compatibility with swappable User model in Django 1.5

Comments (0)

Files changed (1)

 import urllib, time, urlparse
 # Django imports
+from django.conf import settings
 from django.db.models.signals import post_save, post_delete
 from django.db import models
 from django.contrib.auth.models import User
     ('rejected', 'Rejected')
+AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
 def generate_random(length=SECRET_SIZE):
     return User.objects.make_random_password(length=length)
     secret = models.CharField(max_length=SECRET_SIZE)
     status = models.CharField(max_length=16, choices=CONSUMER_STATES, default='pending')
-    user = models.ForeignKey(User, null=True, blank=True, related_name='consumers')
+    user = models.ForeignKey(AUTH_USER_MODEL,
+                             null=True, blank=True, related_name='consumers')
     objects = ConsumerManager()
     timestamp = models.IntegerField(default=long(time.time()))
     is_approved = models.BooleanField(default=False)
-    user = models.ForeignKey(User, null=True, blank=True, related_name='tokens')
+    user = models.ForeignKey(AUTH_USER_MODEL,
+                             null=True, blank=True, related_name='tokens')
     consumer = models.ForeignKey(Consumer)
     callback = models.CharField(max_length=255, null=True, blank=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.