Is it possible to set Django Admin
page to show which user is in which group? And is it possible to be able to add a user into a group using the Django Admin
page? If yes, how?
Now, I'm adding programmatically customers into customers group
and sellers into sellers group
, but I can't see any information in my administration.
This is my registration view
:
def register_customer(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
customer_registration_form = forms.CustomerRegistrationForm(request.POST)
if form.is_valid() and customer_registration_form.is_valid():
new_user = form.save()
new_customer_profile = UserCustomerProfile(user=new_user)
new_customer_profile.save()
customers_group = Group.objects.get(name='Customers')
new_user.groups.add(customers_group)
return render(request, 'registration/complete.html')
else:
#handle errors
customer_registration_form = forms.CustomerRegistrationForm()
form = UserCreationForm()
return render(request, "registration/register.html",
{'form': form, 'customer_registration_form': customer_registration_form})
admin.site.unregister(Group)
as I already have an admin site, and I renamedorigGroupAdmin
toDjangoGroupAdmin
just to stick with the upper case class convention. Thank you very much! – Quaint