Re: [google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-09 Thread Jachin Rupe
Ah, the way back machine comes to the recue again.

Thank you so much for your help. After a little more thought I re-factored 
my form so it's a little simpler now and I don't need to attach errors to 
multiple fields, so I haven't tried it just yet, but I'm sure I'll need to 
do this again in the near future. When I do I'll (try to remember to) post 
an example.

It would sure be cool if Google would put up document all the django 
libraries they support by default. Oh well.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-04 Thread djidjadji
I just found out that they had removed the 0.96 documentation.
The documentation can be found here
http://web.archive.org/web/*/http://www.djangoproject.com/documentation/0.96/

Instead you can redefine the full_clean() method of the Form and
return different data in the exception and set multiple error fields.
Or let the clean methods return a dictionary with clean data and
errors. Based on the return type do different things.
And in the errors part specify for which fields you want to set which errors.
You can use the original method as a template.

2011/2/3 Jachin Rupe :
> It worked great with one caveat. When I raise an error I can only attach it
> to one form field.
> Say I wanted to attach the error message to both the start and end date
> field. Is there a way to do that?
> It looks like one of the fields gets "cleaned" before the other one, so what
> ever one gets cleaned second will have the error message attached to it,
> better then what I had before, but maybe that just doesn't work in 0.96.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-02 Thread Jachin Rupe
It worked great with one caveat. When I raise an error I can only attach it 
to one form field.

Say I wanted to attach the error message to both the start and end date 
field. Is there a way to do that?

It looks like one of the fields gets "cleaned" before the other one, so what 
ever one gets cleaned second will have the error message attached to it, 
better then what I had before, but maybe that just doesn't work in 0.96.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-02 Thread Jachin Rupe
Thanks, that worked great.

Good point about the 1.0 vs 0.96. I tried to find the 0.96 docs but it looks 
like they aren't on the django project's site anymore.

Do you know if they are still up somewhere?

I guess I could probably just get them out of django's source control too.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-02 Thread djidjadji
You don't tell which version of the django forms you use. You link to
a django 1.0 form page but django 0.96 does it a bit different.

In your form subclass define the following functions and raise the same
raise forms.ValidationError(u"You need to pick a start date and time
in the future.")
if needed

class MyForm(Form):
  def clean_startdate(self):
# return cleaned version of start date or raise Validation error
pass
  def clean_enddate(self):
# return cleaned version of end date or raise Validation error
pass

2011/2/2 Jachin Rupe :
> One more thing, if I just throw a validation error, that works fine, but it
> doesn't put the error message on both of the fields.
> raise forms.ValidationError(u"You need to pick a start date and time in the
> future.")

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Can't attach error messages to individual fields in clean()

2011-02-02 Thread Jachin Rupe
One more thing, if I just throw a validation error, that works fine, but it 
doesn't put the error message on both of the fields.

raise forms.ValidationError(u"You need to pick a start date and time in the 
future.")

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.