Questions tagged [django-users]

User model is the default model in Django. It provides many APIs which are helpful for working with users. Django user model is overridable in a Project according to required field.

Django(a high-level Python Web framework) comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions.

894 questions
2
votes
1 answer

Is it possible to create a django_tenant_superuser via management.call_command?

I'm building a multi-tenant project with django-tenant. The issue I'm encountering is that "password" is not a valid flag option. management.call_command( 'create_tenant_superuser', interactive = False, username =…
2
votes
1 answer

Error when creating user from custom model

I am relatively new to Django, but just finished creating a custom user model rather then using the base. When running createsuperuser im getting the following error stack: File…
adamt
  • 37
  • 5
2
votes
2 answers

create django user who can not login

I want to create a user whom I'm using as a ForeignKey and i don't want those users can login to system. I have no idea how to go on. (about setting set_unusable_password() or None, and how to perform it): my accounts.py file is as class…
Ali Aref
  • 1,893
  • 12
  • 31
2
votes
1 answer

Username appearing in django migrations over custom User model with no username

I have written a custom User model, with no username. Still it appears in migrations as primary key and throws unique constraint error while adding new user. Here is my User Model Manager: class UserManager(BaseUserManager): def create_user(self,…
2
votes
1 answer

Change label color of Django user form

I added a user module to my project and I used the default Django user model for that. I've to change the styling to suit my other pages. The background color is black. The problem is default labels and error messages (eg: "username", "password",…
ASIL ADNAN
  • 41
  • 1
  • 7
2
votes
0 answers

DRF auth_token "non_field_errors": [ "Unable to log in with provided credentials." ] using custom user model

I'm trying to create a rest api using an existing database. I am also using drf token authentication and have created tokens for all existing users. When I try to enter my username and password to get my token from my ObtainAuthToken View I receive…
2
votes
0 answers

Django login authentication and session without user models and ORM

For various reasons, I cannot use Django's ORM features. Instead I have to query into a database to check passwords instead of using models. I can already do that. But I can't figure out how to make a custom auth backend work with that. This doc…
2
votes
1 answer

form.is_valid () always returns False in Django

I got a strange bug. I am failing validation if I add an email field. If validation for only 1 username field, then everything works fine. Tell me please, what am I doing wrong? file forms.py: class UserUpdateForm(forms.ModelForm): email =…
Max
  • 55
  • 6
2
votes
1 answer

Django admin login not working when creating new User structure

I am trying to create a new User model with 'AbstractBaseUser' and 'BaseUserManager' but for soemw reason now when creating a new super user, logging in does not work and shows this error: Please enter the correct email and password for a staff…
nalaxos
  • 21
  • 2
2
votes
1 answer

How to check password against previously used passwords in django

I have the following model for storing previously used hashed passwords: class PasswordHistory(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) password = models.CharField(max_length=128, unique=True) created_at =…
Atma
  • 29,141
  • 56
  • 198
  • 299
2
votes
3 answers

Django: Add additional fields to UserCreationForm

Can we add additional fields to UserCreationForm in django. By default there are 5 fields in UserCreationForm: username email first_name last_name password If I want to add additional fields like age, gender then how can I add these in…
L Lawliet
  • 419
  • 1
  • 7
  • 20
2
votes
2 answers

How can I allow users to edit their profiles in Django?

I have a model in models.py like this: class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.DO_NOTHING) phone_number = models.CharField(max_length=50, default='') Birthday = models.CharField(max_length=50,…
Asusoft
  • 352
  • 2
  • 10
2
votes
1 answer

proper name for custom User and Manager in Django

In my django project I've created a customized models for User and its manager class. I named them User (which inherits from AbstractUser) and UserManager (which inherits from BaseUserManager). Given that these are the default django's name for…
dc_Bita98
  • 851
  • 2
  • 17
  • 35
2
votes
2 answers

Django - check if two password hashes are of same raw password

I want to keep track of user password change history, and display a warning if their current password is used by them before. To note, I don't want to prevent a user from setting a password if it is used before, I want to let them set the password,…
Ozgur Akcali
  • 5,264
  • 2
  • 31
  • 49
2
votes
1 answer

Django : table minor_faculty has no column named user_id

Hi I am working on a Django version 2.2.4 application using sqlite3 database. I have a an extension to Django's User model, defined in my models.py as follows: from django.db import models from django.contrib.auth.models import User DEPARTMENT = ( …
Harsh
  • 45
  • 6