是否可以設置Django Admin
頁面來顯示哪個用戶在哪個組中?是否可以使用Django Admin
頁面將用戶添加到組中?如果是,如何?在Django Admin中顯示羣組成員
現在,我將customers group
和賣家sellers group
以編程方式添加到客戶中,但我在我的管理中看不到任何信息。
這是我的註冊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})
Django的1.8,我需要爲'through'不是集團的'屬性使用'模型= User.groups.through'。 user_set' – PaulR