django-users

Django Manager isn't available; 'auth.User' has been swapped for 'users.MyUser'

孤人 提交于 2020-03-03 03:06:48
问题 I created Custom UserModel in Django 1.11 and I need a function which allows users to sign in I think my custom user model is incompatible with my function How can I fix? see error message in the image below : users.models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from apps.teams.models import Team import uuid class MyUserManager(BaseUserManager): def _create_user(self, username, password, **extra_kwargs): user = self.model

Django Manager isn't available; 'auth.User' has been swapped for 'users.MyUser'

喜夏-厌秋 提交于 2020-03-03 03:04:50
问题 I created Custom UserModel in Django 1.11 and I need a function which allows users to sign in I think my custom user model is incompatible with my function How can I fix? see error message in the image below : users.models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from apps.teams.models import Team import uuid class MyUserManager(BaseUserManager): def _create_user(self, username, password, **extra_kwargs): user = self.model

using User.objects.get_or_create() gives invalid password format in django?

我的梦境 提交于 2020-01-13 03:00:13
问题 python manage.py shell >>> from django.contrib.auth.models import User >>> u=User.objects.get_or_create(username="testuser2",password="123") >>> u (<User: testuser2>, True) seems it created the User properly. but when I logged into admin at http://127.0.0.1:8000/admin/auth/user/3/ , I see this message for password Invalid password format or unknown hashing algorithm. Screenshot is attached too. why is it this way and how to create User objects from shell. I am actually writing a populating

Django - Multiple User Profiles

感情迁移 提交于 2020-01-11 14:48:53
问题 Initially, I started my UserProfile like this: from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) verified = models.BooleanField() mobile = models.CharField(max_length=32) def __unicode__(self): return self.user.email Which works nicely along with AUTH_PROFILE_MODULE = 'accounts.UserProfile' set in settings.py . However, I have two different kinds of users in my website, Individuals and Corporate, each

Multiple USERNAME_FIELD in django user model

落爺英雄遲暮 提交于 2020-01-11 04:53:09
问题 My custom user model: class MyUser(AbstractBaseUser): username = models.CharField(unique=True,max_length=30) email = models.EmailField(unique=True,max_length=75) is_staff = models.IntegerField(default=False) is_active = models.IntegerField(default=False) date_joined = models.DateTimeField(default=None) # Use default usermanager objects = UserManager() USERNAME_FIELD = 'email' Is there a way to specify multiple USERNAME_FIELD ? Something like ['email','username'] so that users can login via

django profies and request.user - error

拈花ヽ惹草 提交于 2020-01-05 05:56:10
问题 I'm getting the following error: 'AnonymousUser' object has no attribute 'get_profile' after I added the following middleware, and try to log on to my site without having logged on before: class TimezoneMiddleware(object): def process_request(self, request): try: driver = request.user.get_profile() timezone.activate(driver.timezone) except ObjectDoesNotExist: timezone.activate('UTC') In the traceback, the error occurs at the first line of the try statement. Thanks in advance for the help! 回答1

custom django-user object has no attribute 'has_module_perms'

无人久伴 提交于 2020-01-03 06:49:09
问题 My custom user model for login via email: class MyUser(AbstractBaseUser): id = models.AutoField(primary_key=True) # AutoField? is_superuser = models.IntegerField(default=False) username = models.CharField(unique=True,max_length=30) first_name = models.CharField(max_length=30, default='') last_name = models.CharField(max_length=30, default='') email = models.EmailField(unique=True,max_length=75) is_staff = models.IntegerField(default=False) is_active = models.IntegerField(default=False) date