2👍
✅
Customizing Django auth can be very difficult and that’s why I would recommend looking into 3rd party apps to help you achieve your goals. One you might want to check out is: https://github.com/bee-keeper/django-invitations
0👍
even though it is an old question and no real answer, one way to do most of the stuff (without knowing how to act on the "send password") would be:
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.contrib.auth.forms import UserCreationForm as DjangoUserCreationForm
class UserCreationForm(DjangoUserCreationForm):
password1 = None
password2 = None
def clean(self):
password = get_random_string() # here you want to maybe send a signal which can be picked up or something
self.cleaned_data['password1'] = password
self.cleaned_data['password2'] = password
return super().clean()
class UserAdmin(DjangoUserAdmin):
add_form = UserCreationForm
fieldsets = (
(None, {'fields': ('username',)}),
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'email'),
}),
)
list_filter = tuple()
list_display = ('username', 'email', 'first_name', 'last_name')
admin.site.register(User, UserAdmin)
- [Answered ]-Adding more associations with foreign key
- [Answered ]-Putting a click event for a dialogue box with Django Tables2
- [Answered ]-Django Wagtail ajax contact form
Source:stackexchange.com