Re: Model field validation for admin

2009-11-10 Thread pjrhar...@gmail.com

> > > Hello, I want to make a field optional (blank=True), only if another
> > > text field's options match a certain value in the admin. Is there any
> > > way to do this? Thanks!

You want to do this in a modelform, and then specify that model form
in your admin.py. Put the checks in the overall form clean method (as
it refers to more than one field). In your model allow blank/null.

Peter
--~--~-~--~~~---~--~~
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: Model field validation for admin

2009-11-10 Thread pixelcowboy

Ok, I'll try that.Thanks!


On Nov 10, 10:19 am, rebus_  wrote:
> 2009/11/10 pixelcowboy :
>
>
>
> > Hello, I want to make a field optional (blank=True), only if another
> > text field's options match a certain value in the admin. Is there any
> > way to do this? Thanks!
>
> This is from the top of my head, but you probably want to say
> null=True (i am guessing you'll leave this field empty in some cases)
> and blank=True on certain model field, then override models save()
> method to check for some conditions under which you want or do not
> want to allow the field to be empty.
>
> I am not sure how you would rise validation error from save() though.
--~--~-~--~~~---~--~~
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: Model field validation for admin

2009-11-10 Thread rebus_

2009/11/10 pixelcowboy :
>
> Hello, I want to make a field optional (blank=True), only if another
> text field's options match a certain value in the admin. Is there any
> way to do this? Thanks!
>

This is from the top of my head, but you probably want to say
null=True (i am guessing you'll leave this field empty in some cases)
and blank=True on certain model field, then override models save()
method to check for some conditions under which you want or do not
want to allow the field to be empty.

I am not sure how you would rise validation error from save() though.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Model field validation for admin

2009-11-10 Thread pixelcowboy

Hello, I want to make a field optional (blank=True), only if another
text field's options match a certain value in the admin. Is there any
way to do this? Thanks!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---