Re: unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

Thanks Karen - I think that got it. At least it's looking better than
it has been. Apparently the missing field from 'cleaned_data' was
caused by the wonky way I had it set up before.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to access another field in cleaned_data from clean_

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 2:21 PM, hotani  wrote:

>
> -- Update --
>
> If I make the clean method for 'county', it works. I guess county
> comes after case_no so both are accessible by that time. Weird, but I
> can deal with it. However, that brings me to the 2nd issue with this
> process: Whatever is accessed in the clean method is no longer
> accessible for writing to the database.
>
> If the form clears - everything checks out and I'm ready to write the
> data, "county" is no longer available and a ValueError is returned
> because the field does not accept NULL values. I know I'm missing
> something here, and the docs are terribly sparse on this topic.
>

For multi-field validation, please read:

http://docs.djangoproject.com/en/dev/ref/forms/validation/

especially:

http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

I do not know what this second problem you are referring to is.  If the form
passes validation than it doesn't make any sense that some of the data
"isn't accessible".  Some examples of the code you are trying may help
pinpoint what is going wrong.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

-- Update --

If I make the clean method for 'county', it works. I guess county
comes after case_no so both are accessible by that time. Weird, but I
can deal with it. However, that brings me to the 2nd issue with this
process: Whatever is accessed in the clean method is no longer
accessible for writing to the database.

If the form clears - everything checks out and I'm ready to write the
data, "county" is no longer available and a ValueError is returned
because the field does not accept NULL values. I know I'm missing
something here, and the docs are terribly sparse on this topic.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

I have 2 fields I'm working with in a custom clean method:
- case_no
- county

the clean method is for case_no, so I have this:
--
def clean_case_no(self):
  d = self.cleaned_data
  form_case_no = d['case_no']
  form_county = d['county']
  ...
--

The form fails with KeyError on 'county'. How else can I access this
field for the clean method? I tried using self.is_valid() before
accessing cleaned_data but no change.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---