From 9befd27a26492cda532a40bf0e30772fc4204114 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 29 Jan 2018 16:16:21 +1100 Subject: [PATCH] Whoops, make our new UserManager extend the Django core one, since it turns out it's absolutely mandatory --- users/migrations/0012_auto_20180129_1614.py | 22 +++++++++++++++++++++ users/models.py | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 users/migrations/0012_auto_20180129_1614.py diff --git a/users/migrations/0012_auto_20180129_1614.py b/users/migrations/0012_auto_20180129_1614.py new file mode 100644 index 0000000..f0f4a91 --- /dev/null +++ b/users/migrations/0012_auto_20180129_1614.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.9 on 2018-01-29 05:14 +from __future__ import unicode_literals + +from django.db import migrations +import users.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0011_auto_20180124_1311'), + ] + + operations = [ + migrations.AlterModelManagers( + name='user', + managers=[ + ('objects', users.models.UserManager()), + ], + ), + ] diff --git a/users/models.py b/users/models.py index f6e1170..cf42a50 100644 --- a/users/models.py +++ b/users/models.py @@ -1,5 +1,5 @@ from django.db import models -from django.contrib.auth.models import AbstractUser +from django.contrib.auth.models import AbstractUser, UserManager as DjangoUserManager from django.contrib.sites.models import Site as DjangoSite from django.utils.functional import cached_property from meta.models import ModelMeta @@ -31,7 +31,7 @@ class Site(models.Model): ordering = ('name',) -class UserManager(models.Manager): +class UserManager(DjangoUserManager): def get_queryset(self): return super(UserManager, self).get_queryset().prefetch_related('keys', 'profiles')