-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using with AllAuth #188
Comments
I haven't used AllAuth with this, but off the top of my head, only thing I could see would be to ensure allauth is in the Regarding the email being the field, this comment somewhat relates to #152. I'm thinking of updating UserProfileManager to be more flexible by passing in a User object versus an email string. Then, update the instructions to use your own UserModel and use this package's Manager and define the tenants ManyToMany relationship to link it up. Would something like that help? |
I was able to move past the initial error about the usename field. I updated the forms below from username to email. This is the error I've been running into now:
I created a base app using cookiecutter-django and then added django-tenants and this project. I've updated the This is the UserProfileAdmin it is complaining about from django.contrib import admin
from django.contrib.auth import admin as auth_admin
from listing_service.users.forms import UserAdminChangeForm, UserAdminCreationForm
@admin.register(TenantUser)
class UserProfileAdmin(auth_admin.UserAdmin):
form = UserAdminChangeForm
add_form = UserAdminCreationForm And the two attached forms from django import forms
from django.contrib.auth import forms as admin_forms
from django.contrib.auth import get_user_model
from django.utils.translation import gettext_lazy as _
User = get_user_model()
class UserAdminChangeForm(admin_forms.UserChangeForm):
class Meta(admin_forms.UserChangeForm.Meta):
model = User
field_classes = {"email": forms.EmailField}
class UserAdminCreationForm(admin_forms.UserCreationForm):
"""
Form for User Creation in the Admin Area.
To change user signup, see UserSignupForm and UserSocialSignupForm.
"""
class Meta(admin_forms.UserCreationForm.Meta):
model = User
fields = ("email", )
field_classes = {"email": forms.EmailField}
error_messages = {
"email": {"unique": _("This email has already been taken.")}
} |
It seems like the error is related to the Inherited https://github.com/django/django/blob/main/django/contrib/auth/admin.py#L44 |
Once I switched it from inheriting the UserAdmin it is running. I'll have to see what else is required to get the allauth flows working with this project. |
Also updating the user to use the tenant permission’s groups was needed. class User(UserProfile):
…
@property
def groups(self):
return self.tenant_perms.groups |
FWIW I also had to add an additional property to get this to work for my app:
|
I get a similar problem. Is there a complete solution? |
Hi @andrew-t34. Can you elaborate on what "similar problem" means as I don't want to assume it's specifically with the admin app. Ultimately, I think there should be a documentation section for using with AllAuth written out. |
my solution to work with allauth ( login with username ) and show all the user fields in the admin site, hope it can help:
from django auth/admin.py and appropriate changes
to get this working:
It worked for me. |
i was facing error django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
<class 'account.admin.CustomUserAdmin'>: (admin.E019) The value of 'filter_horizontal[0]' refers to 'groups', which is not a field of 'account.CustomUser'.
<class 'account.admin.CustomUserAdmin'>: (admin.E019) The value of 'filter_horizontal[1]' refers to 'user_permissions', which is not a field of 'account.CustomUser'.
<class 'account.admin.CustomUserAdmin'>: (admin.E116) The value of 'list_filter[1]' refers to 'is_superuser', which does not refer to a Field.
<class 'account.admin.CustomUserAdmin'>: (admin.E116) The value of 'list_filter[3]' refers to 'groups', which does not refer to a Field. and add this to admin.py class CustomUserAdmin(UserAdmin):
...
filter_horizontal = ()
list_filter = ('is_active', 'is_staff') and it works |
This is a great package. I was wondering if there are examples of using this with allauth, or common pitfalls people run into.
I'll updating with information as I run into it. Currently I am working on the AdminCreation, AdminChange, Signup, and SocialSignup forms. The problem I have ran into is we don't use username only email - which is what I personally want.
Thank you!
The text was updated successfully, but these errors were encountered: