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

Longer username in Django 1.7

I want to increase the length of the username in django from 30 to around 80, I know it may be duplicate question but the previous answers are not working, for example https://kfalck.net/2010/12/30/longer-usernames-for-django this is for Django…
vaibhav1312
  • 863
  • 4
  • 13
  • 31
5
votes
1 answer

Add Custom Field to auth_user table in django

I Want to add my custom TrustAdministration Field to Auth_User table in django Here is my Model.py from django.db import models from django.contrib.auth.models import User class Trust(models.Model): name =…
5
votes
0 answers

Multiple registration flows and profile types with django-allauth

I have two kind of users: the first has to pay in oder to register to the site and he can perform a set of actions. The second can register and login for free (with their Facebook or Google or Username&Password) and can perform a different set of…
5
votes
1 answer

How to create view that saves User and UserProfile objects in Django

I have two models in Django: User (pre-defined by Django) and UserProfile. The two are connected via a Foreign Key. models.py: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, related_name="connect") location =…
goelv
  • 2,774
  • 11
  • 32
  • 40
5
votes
1 answer

Django + Wordpress: Integrating user login

I would like to have one users system (preferrably Django's) to rule both Django and Wordpress. The use case is that Django is an application embedded inside a wordpress installation (via iframe or something similar). In order to use the Django,…
scooz
  • 828
  • 2
  • 7
  • 24
4
votes
1 answer

In Django, when I call User.objects.create_user(username, email, password) - why does post_save get called twice?

In views.py I have the following view which gets called when a new user account is registered. All it does is get the username, email, and password from the request, then try to create a user with those credentials. In the code below, "A" gets…
Deonomo
  • 1,583
  • 3
  • 16
  • 25
4
votes
1 answer

How can I reset and prepoulate all users in django?

I'm developing a django application with some complicated user interactions, so I need to do a lot of testing. Is there an easy way to clear out the Users table (and all associated tables) in the database to start fresh? Also, is there a good way to…
Abe
  • 22,738
  • 26
  • 82
  • 111
4
votes
2 answers

How to create users in Django?

I am trying to use Django's user model, but when I cannot create a new user. I already ran python manage.py makemigrations and python manage.py migrate. If I try to run the commands again, I get a "No Changes Detected" message. I was able to create…
4
votes
1 answer

Get Django Custom user model listed under admin app `Authentication and Authorization`

Note my question is similar to this one, however that answer recommend not calling the customised user model User, whereas the official docs and this issue do. I created a custom User model in an app called plug: plug/models.py: from django.db…
run_the_race
  • 1,344
  • 2
  • 36
  • 62
4
votes
1 answer

pytest-django: users created with create_user are always authenticated

I'm trying to write a fixture to generate Django users from custom user model. The weird thing is that the newly created user results authenticated by default, while I expect it to be anonymous. What am I doing wrong? Fixture: import…
Paolo
  • 20,112
  • 21
  • 72
  • 113
4
votes
2 answers

Add user to a group at signup in Django

New to Django here. There are three types of users: Bronze, Silver and Gold with different permissions. All users start out as Bronze when they sign up and then move upwards when they fulfill certain conditions. Therefore I tried to customize the…
user1933205
  • 300
  • 4
  • 12
4
votes
1 answer

django AttributeError: dict object has no attribute 'pk'

I'm making a simple django rest framework project. This is just creating a new user, and logging in. When I used django basic auth user model, everything worked well. But after changing basic user model to custom user, this error comes out when…
Seokchan Yoon
  • 43
  • 1
  • 4
4
votes
4 answers

Use Django User-Model or create a own Model?

I'm currently designing a Django based site. For simplicity lets assume that it is a simple community site where users can log in and write messages to other users. My current choice is wether to use the buildin User-Model or to build something my…
Martin Thurau
  • 7,564
  • 7
  • 43
  • 80
4
votes
3 answers

get current user for 'created_by' field in model class

I'm currently working on a Django app, and I'm trying to set the current user as default on a model, but it doesn't work. created_by = models.ForeignKey(User, default=request.user, null=True, blank=True, on_delete=models.DO_NOTHING,…
Theophile
  • 105
  • 1
  • 1
  • 8
4
votes
2 answers

Django - check if user is authenticated for every url

On my html, I can check if the user is logged in by using the following syntax: {% if user.is_authenticated %}
...
{% else %}

Please Log in

{% endif %} But what should I do if I want to check if the user…
Eric Kim
  • 2,493
  • 6
  • 33
  • 69