Python Forum

Full Version: register the user as staff member - django
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I came across this code and it is registering the user but without having the user part of staff members. How to make that happened?

def register_user(request):
	if request.method == "POST":
		form = UserCreationForm(request.POST)
		if form.is_valid():
			form.save()
			username = form.cleaned_data['username']
			password = form.cleaned_data['password1']
			user = authenticate(username=username, password= password)
			login(request,user)
			messages.success(request,"Registration successful")
			return redirect('store')				
	else:
		form = UserCreationForm()


	return render(request, 'authenticate/register_user.html', {'form':form,})