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
3
votes
2 answers

How to change the user display name to their first name in Django

I am using the Django inbuilt user authentication system, from from django.contrib.auth.models import User. And I have realised that in the admin page it always displays the username of the user. Is it possible to change the def __str__ (self):…
Najaaz
  • 380
  • 5
  • 16
3
votes
1 answer

create_user() missing 1 required positional argument: 'username'

I deleted username field because I wanted user to be able to login with their email address, so I have this in my models.py : class CustomUser(AbstractUser): USER_TYPE = ((1, 'HOD'), (2, 'Staff'), (3, 'Student')) username = None email =…
3
votes
1 answer

In Django, restrict users to particular urls

I have the following urls in my Django application: path('rooms/',views.home,name='home'), models: class ChatRoom(models.Model): eid = models.CharField(max_length=64, unique=True) name = models.CharField(max_length=25) views def…
SAI SANTOSH CHIRAG
  • 2,046
  • 1
  • 10
  • 26
3
votes
3 answers

Marking users as new when created via a backend's authenticate in Django

I have an authentication backend based off a legacy database. When someone logs in using that database and there isn't a corresponding User record, I create one. What I'm wondering is if there is some way to alert the Django system to this fact, so…
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
3
votes
0 answers

Is there a way to separate django admin (superuser) from normal user?

In my Django Rest Framework api I have no human users which interact with my api, but I would like to use the User authentication on these machine users. However, the AbstractBaseUser still locks me in to much with the required email and username…
3
votes
1 answer

How to create Custom User Model in Wagtail 1.8 by writing a new admin.ModelAdmin?

In a Wagtail 1.8 project, I am trying to create a custom user model, which does use no username, but only an email. I want to be able to define extra variables like is_training and show it in the edit form in the admin area under admin/users/edit.…
Henrik
  • 33
  • 4
3
votes
1 answer

How to include forward slash in django username

I am working on a website that requires user username to include forward slash. something like 'CSC/15U/1155' as username. django says 'Enter a valid username. This value may contain only letters, numbers, and @/./+/-/_ characters.'. my question is…
AIbrahim
  • 41
  • 5
3
votes
1 answer

Implementing multiple administration levels in Django

I have decided to move a project from PHP to Python and despite hours of searching, I cannot find a way to implement the following design. I have attempted extending the user class and doing customised Admin Sites but not really got anywhere…
3
votes
2 answers

Using a Custom User the Password Validation from settings are ignored on registration

In Django I created a custom User. My issues is that the default validators are not working, any password is accepted. I expected that the default password validators will work, because I'm inheriting the default Model/Form clases. In Django…
J Mo
  • 43
  • 6
3
votes
1 answer

Django - Get the first and last names of an user

When a user is created, one can add the first and last name in the user's profile. My question is: how can I access this information? If I only wanted the username I would do it with user.get_username. How should I access first name and last name?
ozo
  • 883
  • 1
  • 10
  • 18
3
votes
1 answer

Django Rest Framework - Field username with ".", "-", "_" character

I want allow from my backend API, that any user can be created with characters like .,-,_, ñ between others characters in their username field which is primary_key=True,. I define my custom user (AbstractBaseUser) of this way, in relation to…
bgarcial
  • 2,915
  • 10
  • 56
  • 123
3
votes
1 answer

User OneToOneField in model

I would create a model to extend user profile, my model is this : from django.db import models from django.contrib.auth.models import User class ExtendUser(models.Model): user = models.OneToOneField(User) # phone =…
akus
  • 33
  • 4
3
votes
1 answer

Customizing the Django User model - username as a Primary Key attribute

How to can I create my own user model in Django, in which I want that my P.K be the username field and not the id field autogenerated by Django? I am trying the following: I've create the userprofiles application in where I will create my customize…
bgarcial
  • 2,915
  • 10
  • 56
  • 123
3
votes
7 answers

How to implement password change form in Django 1.9

The url for my python project is here: https://github.com/abylikhsanov/social I am trying to implement the password change form, so the user can change his or her password. How can I implement it? The application should keep track of the…
user4222907
3
votes
1 answer

How is it possible for django to go through DoesNotExist and then raise "Duplicate entry"?

I received the following django error File "./project/auth_backend.py", line 31, in authenticate user.save() ... IntegrityError: (1062, "Duplicate entry 'user_name' for key 'username'") The said file contains the following code (which is based on…
Dynameyes
  • 435
  • 5
  • 15