django-users

Turn off user social registration in django-allauth?

扶醉桌前 提交于 2019-11-30 17:00:27
问题 I noticed looking through the django-allauth templates there's a signup_closed.html users can be redirected to when user registration is closed or disabled. Does anyone who's familiar with that module know if there's a pre-configured setting that can be set in settings.py to turn off new user registration via existing social apps? Or do I need to configure that myself? I've read the full docs for allauth and I don't see any mention of it. Thanks. 回答1: Looks like you need to override is_open

User manager methods create() and create_user()

 ̄綄美尐妖づ 提交于 2019-11-30 03:34:49
问题 I have encountered with some suspicious behavior of create() method of User object manager. Looks like password field isn't required for creating User object if you use this method. In result you get User with blank password . In case when you use create_user method and don't specify password it creates User with unusable password (through to set_unusable_password() ). I am not sure why create() method doesn't raise exception when you try to create user without password - in documentation it

Issue with createsuperuser when implementing custom user model

北慕城南 提交于 2019-11-30 03:21:32
问题 I am trying to implement my own custom user model in Django 1.6 but I am getting this error. Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/gabriel/.virtualenvs/hang_server/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/Users/gabriel/.virtualenvs/hang_server/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in

get current user in Django Form [duplicate]

佐手、 提交于 2019-11-29 22:17:33
Possible Duplicate: get request data in Django form There's part of my Guest Model: class Guest(models.Model): event = models.ForeignKey(Event, related_name='guests') user = models.ForeignKey(User, unique=True, related_name='guests') ... Form to get the response from the Guest: class RSVPForm(forms.Form): attending_d= forms.ChoiceField(choices=VISIBLE_ATTENDING_CHOICES, initial='yes', widget=forms.RadioSelect) attending_b = forms.ChoiceField(choices=VISIBLE_ATTENDING_CHOICES, initial='yes', widget=forms.RadioSelect) number_of_guests = forms.IntegerField(initial=0) comment = forms.CharField(max

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

五迷三道 提交于 2019-11-29 21:44:31
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.auth.forms.UserChangeForm and hooking it into my already-custom UserAdmin object... somehow. But I can

How to extend UserCreationForm with fields from UserProfile

橙三吉。 提交于 2019-11-29 12:31:58
I found this post on how to extend the UserCreationForm with extra fields such as "email." However, the email field is already defined in the pre-built user model. I created an extra model (called UserProfile) that futher extends Django's pre-built User class. How do I get these fields I defined in UserProfile to appear in my UserCreationForm? Add fields as appropriate for your UserProfile model (it's not too easy to use a ModelForm to avoid Repeating Yourself, unfortunately), then create and save a new UserProfile instance in the over-ridden save() function. Adapted from the post you linked

Django - UserProfile m2m field in admin - error

跟風遠走 提交于 2019-11-29 09:45:59
问题 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, db_index=True) cities = models.ManyToManyField(City) class City(models.Model): name = models.CharField(max_length=50) slug = models.SlugField(max_length=50) In admin.py: admin.site.unregister(User) class UserProfileInline(admin.StackedInline): model = UserProfile class

Django Abstract User Error

て烟熏妆下的殇ゞ 提交于 2019-11-28 20:19:30
I am working on extending the User class based on the docs with the code below: from django.contrib.auth.models import AbstractUser class MyUser(AbstractUser): some_extra_data = models.CharField(max_length=100, blank=True) However, I'm returning the following error Reverse accessor for 'User.groups' clashes with reverse accessor for 'MyUser.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'MyUser.groups'. I understand resolving this type of conflict by adding a related_name to FK. How would I resolve it in this scenario? You need to set your AUTH_USER

get current user in Django Form [duplicate]

为君一笑 提交于 2019-11-28 19:47:01
问题 Possible Duplicate: get request data in Django form There's part of my Guest Model: class Guest(models.Model): event = models.ForeignKey(Event, related_name='guests') user = models.ForeignKey(User, unique=True, related_name='guests') ... Form to get the response from the Guest: class RSVPForm(forms.Form): attending_d= forms.ChoiceField(choices=VISIBLE_ATTENDING_CHOICES, initial='yes', widget=forms.RadioSelect) attending_b = forms.ChoiceField(choices=VISIBLE_ATTENDING_CHOICES, initial='yes',

How to use 'User' as foreign key in Django 1.5

落爺英雄遲暮 提交于 2019-11-28 17:10:58
I have made a custom profile model which looks like this: from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.ForeignKey('User', unique=True) name = models.CharField(max_length=30) occupation = models.CharField(max_length=50) city = models.CharField(max_length=30) province = models.CharField(max_length=50) sex = models.CharField(max_length=1) But when I run manage.py syncdb , I get: myapp.userprofile: 'user' has a relation with model User, which has either not been installed or is abstract. I also tried: from django.contrib