django-users

Use Django password widget and change password form in user admin site

落爺英雄遲暮 提交于 2021-02-11 17:09:53
问题 I am extending the user model in Django and have create a PIN number field that is hashing into the database correctly. However, in the Django admin when viewing a user the pin number field is populated with the hash. Is it possible to use the Django password widget: so that the PIN number field is not populated: and therefore by extension use the template for the change password form to also change the pin? 回答1: I don't see why you couldn't use the form. Here's the Django User form: django

Use Django password widget and change password form in user admin site

☆樱花仙子☆ 提交于 2021-02-11 17:08:33
问题 I am extending the user model in Django and have create a PIN number field that is hashing into the database correctly. However, in the Django admin when viewing a user the pin number field is populated with the hash. Is it possible to use the Django password widget: so that the PIN number field is not populated: and therefore by extension use the template for the change password form to also change the pin? 回答1: I don't see why you couldn't use the form. Here's the Django User form: django

Error: You are trying to add a non-nullable field 'password' to account without a default during Django migrations

牧云@^-^@ 提交于 2021-02-11 15:40:52
问题 I am tying to build a custom user model in a Django app, instead of using the built-in one. models.py from django.contrib.auth.models import AbstractBaseUser from django.db import models from django.contrib.auth.models import BaseUserManager class AccountManager(BaseUserManager): def create_user(self, email, password=None, **kwargs): if not email: raise ValueError('Users must have a valid email address.') if not kwargs.get('username'): raise ValueError('Users must have a valid username.')

django 1.9 not creating table for custom user model

徘徊边缘 提交于 2021-02-07 14:43:24
问题 My project name is timecapture Here is relevant portion of timecapture/settings.py INSTALLED_APPS = [ # 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'timecapture', 'timesheet' ] AUTH_USER_MODEL = 'timecapture.TimeUser' And here is timecapture/models.py from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) from django.utils.translation import ugettext_lazy

Send an email if to a Django User if their active status is changed

时间秒杀一切 提交于 2021-02-07 10:46:15
问题 I've built a site that requires membership for some portions. It's a club website so to be a member on the website, you have to be a member in real life. The plan is to have somebody from the Club check for new members (I'll probably have the system send them an email when a user signs up) and then the admin checks the active checkbox under the user's record in the Django admin and saves the user. The problem I'm trying to overcome is we need new, valid users to be notified as to when they

Adding custom action to UserModel's Admin page

可紊 提交于 2021-02-07 06:39:11
问题 Is there any possibility to create custom action in admin page for django UserModel? I want automatize adding user to group (like adding him to staff, set some extra values, etc.), and of course create actions that take these changes back. Thanks for your help. 回答1: Import User in your admin.py unregister it, create new ModelAdmin for it (or subclass the default one) and go wild. It would look something like this I guess: from django.contrib.auth.models import User class UserAdmin(admin

Django Admin Issue - 'NoneType' object has no attribute 'user'

天涯浪子 提交于 2021-01-29 08:25:13
问题 Writing a blog engine with Django 1.5 and using the Django Admin. Everything was fine, until I added a ManyToManyField to a model, and added that field to the ModelAdmin's fieldsets, then I started to get this mysterious error when trying to load the admin page: 'NoneType' object has no attribute 'user' (Full stack trace further on below.) Why would the response object suddenly be None? If I remove the field from the fieldset, everything's fine again. My models look something a bit like this

Can't login with normal user account in django

断了今生、忘了曾经 提交于 2021-01-07 02:43:14
问题 I'm working on an app where I have a personalized User model. I can use the superuser to login, but when I try with a normal user I get an error of wrong password and user name. When I look at the data of the user, I find that the password of normal users isn't hashed. The models definition models.py : from django.db import models from django.contrib.gis.db import models from phonenumber_field.modelfields import PhoneNumberField from django.contrib.gis.db import models as gis_models from

Can't login with normal user account in django

吃可爱长大的小学妹 提交于 2021-01-07 02:42:46
问题 I'm working on an app where I have a personalized User model. I can use the superuser to login, but when I try with a normal user I get an error of wrong password and user name. When I look at the data of the user, I find that the password of normal users isn't hashed. The models definition models.py : from django.db import models from django.contrib.gis.db import models from phonenumber_field.modelfields import PhoneNumberField from django.contrib.gis.db import models as gis_models from

Anonymous user error

蹲街弑〆低调 提交于 2021-01-03 06:25:53
问题 I'm trying to save form data to an anonymous user, however I get the below error when trying to save some form data in a CreateView". I'm not clear what the issue is? ValueError: Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x11126bc18>>": "EUser.user" must be a "User" instance. Models: class EUser(models.Model): online_account = models.BooleanField() supplier1 = models.OneToOneField(SupplierAccount) supplier2 = models.OneToOneField(SupplierAccount)