I am trying to update my user account info through a form. I have the form ok which just displays a password/email field and cleans the email field. I am having a problem with my views. This is the error I get: Manager isn't accessible via User instances. This is my views: my_account function.
def my_account(request):
user = request.user
if request.method == 'POST':
form = MyAccountForm(request.POST)
if form.is_valid():
user = user.objects.get(username=username),
password = user.set_password('password2'),
email = forms.cleaned_data['email']
user.save()
return HttpResponseRedirect('/')
else:
form = MyAccountForm()
variables = RequestContext(request, {
'form': form,
})
return render_to_response(
'my_account.html',
variables
)
where you have
user.objects.get
you want
User.objects.get
objects
is the manager referred to in the error message, and user
is the instance referred to (an instance of User
, the actual class)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.