I have the same need for a simple signup form, created my own AccountForm 
and used 

                profile_fields_form = self.get_profile_fields_form()
                profile_fields = profile_fields_form().fields
                if self._signup:
                    for field in profile_fields:
                        profile_fields[field].widget = forms.HiddenInput()
                self.fields.update(profile_fields)

But i get the error on submit: 

ValueError at /accounts/signup/

The Profile could not be changed because the data didn't validate."

my_cms/my_cms/forms.py in save

   1. 
   
                           profile_form(self.data, self.files, 
instance=profile).save()
   
   
I have seen another post about there being a bug related to this but i'm 
wondering if you solved this completely? all the other profile fields are 
"blank=True" etc so i'm 90% sure its not a simple validation problem?

Any help much appreciated

On Thursday, 28 January 2016 09:59:21 UTC, [email protected] wrote:
>
> That was indeed the way to go, thanks Steve for pointing me into the right 
> direction. I discovered that the AccountForm class already has got an 
> attribute _signup which does what you suggest. 
>
> I subclassed the AccountForm. If I am not mistaken I had to hide the 
> profile form fields during signup (not take them out all together during 
> signup) in order to avoid a validation error.
>
> The only small drawback left is that I haven't figured our how to make the 
> optional fields "first_name" and "last_name" optional in the AccountForm.
>
> Chris
>
> Am Dienstag, 26. Januar 2016 23:53:18 UTC+1 schrieb Stephen McDonald:
>>
>> I'd suggest using a custom form class, and checking for a bound user 
>> object in its __init__ method, which if present indicates it's the update 
>> form, and not signup, and you can then modify the attributes of each field 
>> programmatically. This would probably turn out to be less code that 
>> defining a form class for each.
>>
>> On Wed, Jan 27, 2016 at 7:04 AM, <[email protected]> wrote:
>>
>>> I want to allow new users to register to a mezzanine based site with 
>>> minimal information (i.e. email and password) and allow them to update 
>>> their profile information once they are registered. Therefore I would like 
>>> to display a form with only the two required fields during signup and the 
>>> "full" ProfileForm during profile_update. 
>>>
>>> Looking at the code in mezzanine.accounts I understand that "signup" 
>>> view as well as the "profile_update" view use the same form (i.e. 
>>> ACCOUNTS_PROFILE_FORM_CLASS). I know I could overcome this by writing my 
>>> custom signup view but is there any other way to solve this so I can keep 
>>> using the build-in code?
>>>
>>> If not: Would it make sense to allow the definition of different form 
>>> classes for signup and profile_update? Many modern websites try to 
>>> encourage registration by asking only for minimal information during 
>>> registration but allow users to add addtional profile information later.
>>>
>>> Regards Chris
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Mezzanine Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Stephen McDonald
>> http://jupo.org
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to