This to be done through user defined admin page and not the Django admin page. I would like to access and edit the user details of other users that have registered to my site. I already have a self edit function in my views but would like to add more accessibility to the admin role in case of user emergency.
This is my self edit views code. What should be the value to insert into instance field (I assume) to get the details of the user the admin selects.
if request.method == "POST":
form = NewEditForm(request.POST, instance=request.user)
Sform = StudentForm(request.POST, instance=request.user)
if form.is_valid() and Sform.is_valid():
user = form.save()
student = Sform.save(commit=False)
student.user = user
student.save()
messages.success(request, ("Profile updated."))
return HttpResponseRedirect("/clubhomepage")
messages.error(request, "Unsuccessful update. Invalid information.")
else:
form = NewEditForm(instance=request.user)
Sform = StudentForm(instance=request.user)
return render(request=request, template_name="App2/edituser.html", context={"edit_form": form, "Student": Sform })
I am still kinda new to django so any help would be appreciated.