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
10
votes
4 answers

Django: Why create a OneToOne to UserProfile instead of subclassing auth.User?

Note: If you are tempted to 'answer' this question by telling me that you don't like django.contrib.auth, please move on. That will not be helpful. I am well aware of the range and strength of opinions on this matter. Now, the question: The…
10
votes
6 answers

ValueError in Django when running the "python manage.py migrate" command

I needed to add more fields to Django's User model, so I created a custom model class (named Accounts in an app named accounts) that extends Django's AbstractUser class. After that, I updated my settings.py file, defining the AUTH_USER_MODEL…
Inyavic Sage
  • 145
  • 1
  • 2
  • 11
9
votes
3 answers

Django how to delete user's profile and posts and all assocation after user deleted?

I'm writing a django project. And want to know after user deletes his own account, is there a way django build-in to auto delete all object related to this user(e.g. some generic foreign_key)? Or I should use signal "post_delete" to delete every…
Xinghan
  • 255
  • 1
  • 3
  • 8
9
votes
2 answers

How can I check if an user is superuser in django

I'm listing registered users on a ListView page and I'm trying to show if user is superuser or not. My main user is created with python manage.py createsuperuser command and I'm sure it is a superuser beacuse I've checked from admin panel too. When…
Tech
  • 734
  • 1
  • 6
  • 20
9
votes
1 answer

Django - UserProfile m2m field in admin - error

My models: class UserProfile(models.Model): TYPES_CHOICES = ( (0, _(u'teacher')), (1, _(u'student')), ) user = models.ForeignKey(User, unique=True) type = models.SmallIntegerField(default=0, choices=TYPES_CHOICES,…
robos85
  • 2,484
  • 5
  • 32
  • 36
9
votes
1 answer

How to use Django User Groups and Permissions on a React Frontend with Django Rest Framework

I am using Django Rest Framework with React on the Frontend. I am using Token Athentication and its all working fine. I now have a requirement of making sure different users can access different things depending on their rights. This is possible…
manpikin
  • 2,200
  • 1
  • 19
  • 19
9
votes
2 answers

Adding custom action to UserModel's Admin page

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…
radious
  • 812
  • 6
  • 21
9
votes
4 answers

User roles schema on Django

A great greetings community My question is related with the kind of manage users and the schema users in Django, In beginning I ask to you apologize just in case that my questions can will be too "newbies" or without sense, I am starting to related…
bgarcial
  • 2,915
  • 10
  • 56
  • 123
9
votes
4 answers

Django - User full name as unicode

I have many Models linked to User and I'd like my templates to always display his full_name if available. Is there a way to change the default User __unicode__() ? Or is there another way to do it ? I have a profile model registered where I can…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
8
votes
2 answers

ForeignKey to a Model field?

I want a foreign key relation in my model with the username field in the User table(that stores the user created with django.contrib.auth.forms.UserCreationForm). This how my model looks: class Blog(models.Model): username =…
8
votes
5 answers

Django custom user model and usermanager

i'm building a web application with Django 1.5. I'm using a custom User model with a custom UserManager. I followed the instructions and examples of the official Django documentation. Now, when i'm trying to create a new user via …
7tupel
  • 151
  • 2
  • 2
  • 5
7
votes
1 answer

Manage UserCreationForm properties and fields

I am new in Django and even after trying thoroughly to find an answer for this question, I couldn't find any. =/ I am using UserCretionForm to create my users and I wanted to know a couple of things: 1 - How can I manage this form's properties?…
Lucas Rezende
  • 2,516
  • 8
  • 25
  • 34
7
votes
4 answers

Django migrate model with user in a foreignkey fails

Im trying to migrate my django model: from django.contrib.auth.models import User class Post(models.Model): headline = models.CharField(max_length=200) slug = models.SlugField(max_length=200) body = models.TextField(blank=True,…
Tomas Jacobsen
  • 2,368
  • 6
  • 37
  • 81
7
votes
8 answers

Django 1.5: Accessing custom user model fields in models.py

I'm working on a Django 1.5 project and I have a custom user model (let's call it CustomUser). Another app (SomeApp) needs to reference this custom user model. For the purposes of ForeignKey and such, the Django documentation says to use User =…
askvictor
  • 3,621
  • 4
  • 32
  • 45
6
votes
2 answers

In Django, how do you pass a ForeignKey into an instance of a Model?

I am writing an application which stores "Jobs". They are defined as having a ForeignKey linked to a "User". I don't understand how to pass the ForeignKey into the model when creating it. My Model for Job worked fine without a ForeignKey, but now…
user1216674
  • 81
  • 1
  • 4