I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-19 Thread sashank reddy
Hi, I have been trying to extend the UserCreationForm and have a form which performs user registration and adds email and the names. In addition I am using a choice field that allows a list down of existing groups so that you can assign the user to an group immediately upon creation. The prob

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-19 Thread Tom Evans
On Wed, Mar 19, 2014 at 3:40 PM, sashank reddy wrote: > Hi, > > I have been trying to extend the UserCreationForm and have a form which > performs user registration and adds email and the names. > In addition I am using a choice field that allows a list down of existing > groups so that you can as

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-19 Thread sashank reddy
Hi Tom, What do you mean callable? I tried changing desig_group = forms.ChoiceField(choices=choice_desig()) to desig_group = forms.ChoiceField(choices=choice_desig) It gave error 'function' object is not iterable. But I want to know if the following would work. desig = forms.ModelChoiceField(

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-20 Thread sashank reddy
Hi Tom, I have not understood what you have said. Shouldn't choice_desig be called every time I instantiate it in the view with the form = New_user_form(). I thought I was creating an object of New_user_form every time I do that. Regards, Preetam On Wednesday, 19 March 2014 22:11:52 UTC+5:30,

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-20 Thread Tom Evans
On Thu, Mar 20, 2014 at 10:12 AM, sashank reddy wrote: > Hi Tom, > > I have not understood what you have said. Shouldn't choice_desig be called > every time I instantiate it in the view with the form = New_user_form(). I > thought I was creating an object of New_user_form every time I do that. Th

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-20 Thread sashank reddy
Hi Tom, I did try an override meanwhile. I added, def initialize_designation(self): print("Initializing designation") self.desig_group = forms.ChoiceField(choices=choice_des()) return to my form class. This will override the desig_group that is previously declared. I call this in the view after

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-20 Thread sashank reddy
Tom, In addition it still doesn't explain why I am unable to traceback the point of exception. How can there be an exception when the only thing there are are few perfect prints I am always invariably getting the "Validation completed print" for desig_name field. Then I get "BaseForm: _clea

Re: I am unable to get the choice field to validate on creating users. it doesn't make sense at all.

2014-03-21 Thread sashank reddy
Hi Tom, As per your first suggestion I tried a ModelChoiceField in place of ChoiceField. It also results in a validation error. I am putting my new code here. = class New_user_form(UserCreationForm): email = forms.Ema