List Info

Thread: Validators in a model's validator_list (m-r)




Validators in a model's validator_list (m-r)
user name
2006-04-25 15:18:41
Christian Schneider wrote:
> On 4/25/06, Michael Radziej <mirnoris.de> wrote:
>>
>> Christian Schneider wrote:
>>> Michael,
>>>
>>> I'm still using a generic view. I played with
some custom functions
>> before
>>> and they were called so I'd hoped that it
would work with the validator
>>> objects as well.
>> I looked in the source. Aha! First parameter to
RequiredIfOtherField is
>> the *name* of the field (a string, not a field).
>>
>> Please try and report ...
> 
> 
> nothing's happening, :-(
> 
> Even if it worked would validation stop if the
referenced field didn't have
> the required value? That is: Field 1 is required when
field 2 has value "x"
> and field 2's value is "y". Field 1 is
blank which it should be allowed to
> but would validation stop after evaluating the
RequiredIfOtherField
> validator runs (if it even runs first)?

I don't know what you mean with "stop". I think
each validator will be
executed, but they will take into account whether
record_type has the
right value.

Anyway, I personally give up :-(

You can try to find out what's happening:

- create your own validator that always raises a
ValidationError (see in
the sources for core.validators to see how)
- add this to your validator list
- do you get a validation message?
  - if not, do something like "raise Blablabla"
which should immediately
result in a backtrace when called. What's happening now?
  - else, change the source of core.validators in Django;
raise
Blablabla in the __call__() method. Do you get the error
message?


You get the picture ...

Hope that helps a little bit.

I created a ticket to add documentation for this module
(#1680)


Michael


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Validators in a model's validator_list (m-r)
user name
2006-04-25 15:26:07
On 4/25/06, Michael Radziej <noris.de">mirnoris.de&gt; wrote:

Christian Schneider wrote:
>; On 4/25/06, Michael Radziej <noris.de">mirnoris.de&gt; wrote:
>;>
>&gt; Christian Schneider wrote:
>;>> Michael,
&gt;>>
>>&gt; I'm still using a generic view. I played with some custom functions
>> before
>;>> and they were called so I'd hoped that it would work with the validator
>>>; objects as well.
>;> I looked in the source. Aha! First parameter to RequiredIfOtherField is
>>; the *name* of the field (a string, not a field).
&gt;>
>> Please try and report ...
>
&gt;
> nothing's happening, :-(
>
> Even if it worked would validation stop if the referenced field didn't have
> the required value? That is: Field 1 is required when field 2 has value "x&quot;
> and field 2's value is "y&quot;. Field 1 is blank which it should be allowed to
> but would validation stop after evaluating the RequiredIfOtherField
> validator runs (if it even runs first)?

I don't know what you mean with "stop". I think each validator will be
executed, but they will take into account whether record_type has the
right value.

Anyway, I personally give up :-(

You can try to find out what's happening:

- create your own validator that always raises a ValidationError (see in
the sources for core.validators to see how)
- add this to your validator list
- do you get a validation message?
&nbsp; - if not, do something like "raise Blablabla&quot; which should immediately
result in a backtrace when called. What's happening now?
&nbsp; - else, change the source of core.validators in Django; raise
Blablabla in the __call__() method. Do you get the error message?


You get the picture ...

OK, will try that tomorrow.
 

Hope that helps a little bit.

Yes, it does, thanks a lot!
&nbsp;

I created a ticket to add documentation for this module (#1680)

thanks.
&nbsp;
Best regards

chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users"; group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to django-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Validators in a model's validator_list (m-r)
user name
2006-04-25 15:26:07
On 4/25/06, Michael Radziej <noris.de">mirnoris.de&gt; wrote:

Christian Schneider wrote:
>; On 4/25/06, Michael Radziej <noris.de">mirnoris.de&gt; wrote:
>;>
>&gt; Christian Schneider wrote:
>;>> Michael,
&gt;>>
>>&gt; I'm still using a generic view. I played with some custom functions
>> before
>;>> and they were called so I'd hoped that it would work with the validator
>>>; objects as well.
>;> I looked in the source. Aha! First parameter to RequiredIfOtherField is
>>; the *name* of the field (a string, not a field).
&gt;>
>> Please try and report ...
>
&gt;
> nothing's happening, :-(
>
> Even if it worked would validation stop if the referenced field didn't have
> the required value? That is: Field 1 is required when field 2 has value "x&quot;
> and field 2's value is "y&quot;. Field 1 is blank which it should be allowed to
> but would validation stop after evaluating the RequiredIfOtherField
> validator runs (if it even runs first)?

I don't know what you mean with "stop". I think each validator will be
executed, but they will take into account whether record_type has the
right value.

Anyway, I personally give up :-(

You can try to find out what's happening:

- create your own validator that always raises a ValidationError (see in
the sources for core.validators to see how)
- add this to your validator list
- do you get a validation message?
&nbsp; - if not, do something like "raise Blablabla&quot; which should immediately
result in a backtrace when called. What's happening now?
&nbsp; - else, change the source of core.validators in Django; raise
Blablabla in the __call__() method. Do you get the error message?


You get the picture ...

OK, will try that tomorrow.
 

Hope that helps a little bit.

Yes, it does, thanks a lot!
&nbsp;

I created a ticket to add documentation for this module (#1680)

thanks.
&nbsp;
Best regards

chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users"; group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to django-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )