On Mon, 2009-11-16 at 17:57 +0100, Dennis Kaarsemaker wrote: > On Mon, Nov 16, 2009 at 5:12 PM, Adam Stein <a...@eng.mc.xerox.com> wrote: > > Running Django v1.1.1 on Apache v2.2.8 with Firefox v3.5.4. > > > > I have a very simplified and unreal example below to demonstrate what's > > happening. > > > >8 -- > > > > def clean(self): > > cleaned = self.cleaned_data > > > > if not cleaned.has_key("string2") and > > cleaned.has_key("string1"): > > cleaned["string2"] = string1 > > > > return cleaned > >8 -- > > > > What happens is that Django comes back with an error message because > > 'string2' is required and has no associated value. Is there any way to > > set a field value that get's POST'd? > > clean() is run after the built-in validation and per-field validation. > You'll want to copy request.POST, set the value there, and then feed > it to the form. Or make string2 not required and do it in clean the > way you do now. >
Thanks for responding. I'll have to look into using POST. The problem with NOT requiring string2 is that I still can't change the value. Instead of checking if it's not there, I check for an empty string: if cleaned["string2"] == "": cleaned["string2"] = string1 which means an empty string goes along with POST, not the value I set. -- Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com Disclaimer: Any/All views expressed here have been proven to be my own. [http://www.csh.rit.edu/~adam/] -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.