Python Forum
register the user as staff member - django
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
register the user as staff member - django
#1
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,})
Linenloid likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Knowing User's Connection Type in Django Dexty 2 1,583 Apr-27-2022, 11:54 AM
Last Post: Dexty
  Send email to gmail after user fill up contact form and getting django database updat Man_from_India 0 2,104 Jan-22-2020, 03:59 PM
Last Post: Man_from_India
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,306 Jun-30-2019, 12:21 AM
Last Post: scidam
  sending email from admin to user in django anjana 0 3,252 Jun-07-2019, 12:01 PM
Last Post: anjana
  RelatedObjectDoesNotExist: User has no profile. Django 1.11 m0ntecr1st0 1 12,570 Feb-21-2019, 01:00 AM
Last Post: m0ntecr1st0
  Django packages for website with paid user accounts jmarchini 2 3,533 Jan-08-2018, 09:10 AM
Last Post: SarbjitGrewal
  Saving username as first name while adding user in django admin prithvi 0 4,406 Aug-10-2017, 06:50 PM
Last Post: prithvi
  Django allauth saving custom user profile fields with signup form prithvi 1 10,498 Aug-08-2017, 03:51 PM
Last Post: prithvi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020