django-users

User roles schema on Django

做~自己de王妃 提交于 2019-12-05 09:27:37
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 me with the Django Users schemas and their different possibilities of work in the projects. I have the following situation. I am building an application in which I will have three differents user types: Medical Patient Physiotherapist I am using the default Django authentication scheme (django.contrib.auth). Initially, I did think in this scheme of

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

吃可爱长大的小学妹 提交于 2019-12-05 06:47:51
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 = settings.AUTH_USER_MODEL However, some functions in SomeApp.models need to access what would have formerly been known as User.objects . But User is now a string and not a class, so User.objects fails. The alternative would be from django.contrib.auth import get_user_model User = get_user_model() Which works in other modules, but when I use this in

Subclassing AbstractUser in Django for two types of users

你说的曾经没有我的故事 提交于 2019-12-04 21:23:32
I'm developing a school database system in Django 1.5, and was planning on having a number of different user types (Student, Staff, Parent) which subclass AbstractUser (actually, another abstract subclass of AbstractUser). I was just attempting to add an externally developed app to my system, which uses User in a ForeignKey for some of its models, however, this fails as my user type is not a 'User' instance. I can't set the apps models to use AbstractUser as one can't use abstract classes for Foreign Keys. I was then considering adding to my settings.py AUTH_USER_MODEL = 'myapp.MyUser' and

Django - User full name as unicode

Deadly 提交于 2019-12-04 21:13:24
问题 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 define the __unicode__() , should I link all my models to it ? Seems not a good idea to me. Imagine I need to display the form for this object class UserBagde user = model.ForeignKey(User) badge = models.ForeignKey(Bagde) I will have to select box with

Django custom user model and usermanager

无人久伴 提交于 2019-12-04 06:55:04
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 UserManager.create_user(...) i'm getting a NoneType error: It seems the UserManager's attribute models is of type None. I think i'm setting up the UserManager correctly in the User model ( objects = UserManager() ) I really don't know where i'm making a mistake. Booth my coding partners and i are new to Django. Maybe you can help us out. Here is the code: class

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

落爺英雄遲暮 提交于 2019-12-04 02:48:29
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 property : AUTH_USER_MODEL = 'accounts.Accounts' I then created a migration file for the custom model using the python manage.py makemigrations command. After that, I ran the python manage.py migrate command and I got this error message: ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'accounts.accounts', but app 'accounts'

How do I prevent permission escalation in Django admin when granting “user change” permission?

老子叫甜甜 提交于 2019-12-03 18:27:44
问题 I have a django site with a large customer base. I would like to give our customer service department the ability to alter normal user accounts, doing things like changing passwords, email addresses, etc. However, if I grant someone the built-in auth | user | Can change user permission, they gain the ability to set the is_superuser flag on any account, including their own. (!!!) What's the best way to remove this option for non-superuser staff? I'm sure it involves subclassing django.contrib

seperate 'admin' interfaces for different user types in django

核能气质少年 提交于 2019-12-03 15:55:47
I have recently being trying to create a project which has several levels of user involved. (Just an example of an abbreviated and rough schema) ME (Super User) Client (s) Customer (s) Survey Collections SurveyUser (s) Invitee (s) Surveys Invitee (s) (invitee is a child of both survey and user) Questions Etc I would ideally have: www.example.com/client/ go to a client interface which you had to be a client to access www.example.com/customer/ go to a customer interface which you had to be a customer to access I have already established that using a customised Django admin interface for all of

Django - User full name as unicode

自古美人都是妖i 提交于 2019-12-03 13:07:24
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 define the __unicode__() , should I link all my models to it ? Seems not a good idea to me. Imagine I need to display the form for this object class UserBagde user = model.ForeignKey(User) badge = models.ForeignKey(Bagde) I will have to select box with __unicodes__ of each object, won't I ? How can I have full names in the user's one ? Francis

Django 1.5 custom User model error. “Manager isn't available; User has been swapped”

吃可爱长大的小学妹 提交于 2019-12-03 08:42:59
问题 I extend the django user model as described in the dev doc. I wan't to keep most of the original User model features so I extend the AbstractUser class. I've defined in settings.py: AUTH_USER_MODEL = 'myapp.CustomUser' My user class: class CustomUser(AbstractUser): custom_field = models.ForeignKey('OtherModel') objects = UserManager() Everything seems to work fine but when I try to make it managed by the admin site: admin.site.register(CustomUser, UserAdmin) I get this error on the admin