Ohhhh thank you! I didn't know about self.data! That's exactly what I
was looking for.

It works now. Thanks!

Yo'av

On Nov 8, 4:22 pm, Martin Ostrovsky <martin.ostrov...@gmail.com>
wrote:
> What about checking the raw POST for existence of data? So in your
> form, checking self.data.has_key('some_key')
>
> On Nov 8, 9:15 am, "Yo'av Moshe" <bje...@gmail.com> wrote:
>
>
>
> > Hey,
>
> > I tried this method with no success.
>
> > Adding .clean to my Article's ModelForm and checking it's
> > self.instance.tags.all(), gives me this ValueError:
> > 'Article' instance needs to have a primary key value before a many-to-
> > many relationship can be used.
>
> > Actually this seems right, since if my Article isn't even saved yet,
> > how can I check it's tags? They don't even exist AFAIK.
>
> > So I thought the way to go was by by checking the form it self. The
> > problem is that Article's ModelForm .clean_data doesn't include my
> > Tag's form, since it's included inline as a seperated form. If I try
> > to use .clean_data on Tag's inline ModelForm it actually works - I can
> > count and validate whatever the user wrote in the Tag's form - but
> > only if the user typed *something*, which is exactly what I'm trying
> > to validate. If the user didn't put anything in Tag's inline ModelForm
> > - .clean_data doesn't get called at all, and no validation is being
> > done.
>
> > I hope I was understood, it's a bit of a mess...
>
> > Is there anyway to go from here? Did I use .clean correctly?
>
> > Thank you for your kind help,
> > Yo'av
>
> > On Nov 7, 12:53 am, Shawn Milochik <sh...@milochik.com> wrote:
>
> > > Add a clean() method to your ModelForm, and raise a forms.ValidationError 
> > > if self.instance.whatever.all().count() == 0.
>
> > > Shawn

-- 
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=en.

Reply via email to