Re: UserChangeForm not working
Hi Karen, I did finally get this figured out, but decided not to implement the functionality after all :) Thanks, Brandon On Dec 5, 7:47 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Dec 5, 2008 at 3:18 AM, Brandon Taylor <[EMAIL PROTECTED]>wrote: > > > > > > > Hi everyone, > > > I want to allow users to change their username in a non-admin form. I > > have a login form already working, and I can successfully show user > > information. I have granted the change user permission to the user > > that is logged in. > > > When I pull in the UserChangeForm from contrib.auth.forms and hand it > > a user instance, the username field is populated correctly. > > > So, I have a simple view action (pseudo code): > > > if request.method == 'POST': > > form = UserChangeForm(data=request.POST) > > if form.is_valid(): > > form.save() > > > but I can never get the form to validate. I can get it to fail > > correctly, but even if I put in a value that I know isn't currently in > > use, the form will still not validate. I tried making a custom form to > > update the username property and do the same validation, just in my > > own form instance, but that didn't work either. The new username > > property wasn't saving to the database. > > > Does anyone have any experience with this form from auth? Any help > > appreciated! > > No, but I'm not sure this has anything to do specifically with auth an its > models/forms. You aren't passing in the user instance when you populate the > form with the POST data. You need to, just as you did when creating the > form for the GET request. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: UserChangeForm not working
On Fri, Dec 5, 2008 at 3:18 AM, Brandon Taylor <[EMAIL PROTECTED]>wrote: > > Hi everyone, > > I want to allow users to change their username in a non-admin form. I > have a login form already working, and I can successfully show user > information. I have granted the change user permission to the user > that is logged in. > > When I pull in the UserChangeForm from contrib.auth.forms and hand it > a user instance, the username field is populated correctly. > > So, I have a simple view action (pseudo code): > > if request.method == 'POST': >form = UserChangeForm(data=request.POST) >if form.is_valid(): >form.save() > > but I can never get the form to validate. I can get it to fail > correctly, but even if I put in a value that I know isn't currently in > use, the form will still not validate. I tried making a custom form to > update the username property and do the same validation, just in my > own form instance, but that didn't work either. The new username > property wasn't saving to the database. > > Does anyone have any experience with this form from auth? Any help > appreciated! > No, but I'm not sure this has anything to do specifically with auth an its models/forms. You aren't passing in the user instance when you populate the form with the POST data. You need to, just as you did when creating the form for the GET request. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
UserChangeForm not working
Hi everyone, I want to allow users to change their username in a non-admin form. I have a login form already working, and I can successfully show user information. I have granted the change user permission to the user that is logged in. When I pull in the UserChangeForm from contrib.auth.forms and hand it a user instance, the username field is populated correctly. So, I have a simple view action (pseudo code): if request.method == 'POST': form = UserChangeForm(data=request.POST) if form.is_valid(): form.save() but I can never get the form to validate. I can get it to fail correctly, but even if I put in a value that I know isn't currently in use, the form will still not validate. I tried making a custom form to update the username property and do the same validation, just in my own form instance, but that didn't work either. The new username property wasn't saving to the database. Does anyone have any experience with this form from auth? Any help appreciated! Brandon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---