On Wed, 2007-04-04 at 14:41 -0700, [EMAIL PROTECTED] wrote: > Hey All, > > I'm trying to use newforms to create a form to login on my site > (there's some stuff in the userprofile which prevents me from using > ths standard django.contrib.auth.views.login view) > > I nearly have everything set up just as I'd like it.. but it seems > that when newforms validators have performed their stuff on my form, > and found no validation errors of their own, they won't let me add > anything to the empty list which calling form['fieldname'] will give > you. > > I've tried form['fieldname'].append('whatever') and form['fieldname'] > += ['whatever'] -- both with no avail. > > Could someone perhaps explain to me what I could do to work around the > AttributeError that I get every time I try something like this. For > the record, I can append to the list when there _are_ validation > errors. Seems strange to me.
Rather than rustle through the code to work this out, I'll just explain how I would go about debugging this: AttributeError suggests you are calling .append() on something that isn't a list. So I would first look at what the type of form['fieldname'] is in the cases where you are getting the error. I suspect you will find it is something like None. Then I would look at how errors are put into the error list in the standard clean_data() functions. What do they (or their callers) do that is different from what you are doing? Look for everywhere that form['fieldname'] is created or modified in newforms/forms.py, particularly in the Form class. That should give you a better idea about what the root cause of the problem is and also show you how Django itself deals with those fields so that you can emulate it more closely. Regards, Malcolm > > Many Thanks, > Oliver > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---