django-authentication

TypeError: create_user() got multiple values for keyword argument 'name'

﹥>﹥吖頭↗ 提交于 2019-12-11 02:59:12
问题 I'm trying to create custom authentication in Django where the identifier is an email, there is a required field called name and a password field. While creating the superuser, i'm getting an error. TypeError: create_user() got multiple values for keyword argument 'name' Here is my models.py from django.db import models from django.contrib.auth.models import User from django.conf import settings from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) class MyUserManager

Password Reset only by Username [closed]

家住魔仙堡 提交于 2019-12-11 02:57:58
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I Implimented django password reset using email but currently want to restrict to only username so that user can change password only by using username. tried django built-in and plugin but unable to set to only username . Any suggestions would be appreciated 回答1: Write your own

Is there a way to send a user email when user object is created?

佐手、 提交于 2019-12-10 22:17:27
问题 In the system I am building user CAN NOT register them selves. The users are added by one of the system admins. So there is no user registration form or view. The registration is only being done in the admin so I guess that the send_mail has to be over there also (or am I wrong)? I need to send an automatic email to the user when he/she is being created and only then (not on every save of the model). Can any one help with this? Is there a built-in something for that? or how do I do that? I've

user.groups.add(group) or group.user_set.add(user), Which is better and why ? or difference between them

大城市里の小女人 提交于 2019-12-10 18:14:07
问题 I am trying to extend django.contrib.auth and came accross adding a user into a group, which can be done in 2 ways. I was just wondering why is it like so, and what are the advantages of one over the other. 回答1: They do the exact same thing. A many-to-many relation consists of an intermediate table with a foreign key to both models. user.groups.add(group) will create an entry in that table where the foreign keys point to the user and group instances. The same happens with group.user_set.add

Django - Error Message in Custom Auth Backend

杀马特。学长 韩版系。学妹 提交于 2019-12-10 18:13:35
问题 I have written a custom auth backend by extending the defalut ModelBackend. Is it possible to send a custom error message to login screen? As of now it is displaying the default message. 回答1: The error messages are coming as ValidationError exceptions raised by django.contrib.auth.forms.AuthenticationForm . You would need to extend the Authentication Form or implement your own authentication form to change it's error messages. 回答2: You can raise a django ValidationError from django.core

Django - Read the current's user authentication backend class

穿精又带淫゛_ 提交于 2019-12-10 17:15:59
问题 I am using a custom authentication backend with Django, to automatically create and login users from a legacy system. My Backend class is this: from django.contrib.auth.backends import ModelBackend from django.contrib.auth.models import User from sfi.models import Employee import base64, hashlib class SFIUserBackend(ModelBackend): def authenticate(self, username=None, password=None): if not username or not password: return digest = base64.standard_b64encode(hashlib.md5(password).digest())

Django - how to have models for registered site users and non-site users?

怎甘沉沦 提交于 2019-12-10 15:08:08
问题 I have a Trip model which can have many participants subscribed for a given trip and one owner. The participans are users registered on the site, but I also want to be able to add 'offline' users to the trip, users who do not have accounts on the site, so that I could keep track of all the users coming. The owner and participatns are linked to Userena user profile (side question: maybe linking directly to User would be better? But how would I get full_name to see as selection in inline admin

Django - user is_active

谁说我不能喝 提交于 2019-12-10 13:22:42
问题 This is my user authentication method: def user_login(request): if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username=username, password=password) if user: if user.is_active: login(request, user) return HttpResponseRedirect(reverse('index')) else: print('TEST') messages.info(request, 'Inactive user') return HttpResponseRedirect(reverse('index')) else: messages.error(request, 'Invalid username/password!')

How do I create a Login System in Django Using Sessions?

≡放荡痞女 提交于 2019-12-10 12:16:24
问题 I am trying to create a website which is authenticated by a custom login. But I have a custom Model for users. How do I authenticate my Website from anonymous Users. Is it possible to create login systems using based on sessions. Actually this is my first django project. Please Guide me. Thank you. 回答1: While login, after checking username and password create a session in which set their user object or it's object id in it. In this case i kept user id. def login(request): if request.method ==

Not able to authenticate with correct username and password in Django?

廉价感情. 提交于 2019-12-10 11:57:21
问题 I am using Django 1.5. My user model is: class User(AbstractBaseUser): #id = models.IntegerField(primary_key=True) #identifier = models.CharField(max_length=40, unique=True, db_index=True) username = models.CharField(max_length=90, unique=True, db_index=True) create_time = models.DateTimeField(null=True, blank=True) update_time = models.DateTimeField(null=True, blank=True) email = models.CharField(max_length=225) #password = models.CharField(max_length=120) external = models.IntegerField(null