On Jun 27, 9:41 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-06-27 at 02:26 -0700, AnaReis wrote:
> > Hi again,
> > This is getting very frustrating because I can't make this work...
> > This is exactly what I wrote in the files:
>
> In future, please remember that when you send a message like this, a lot
> of us are reading it through an e-mail interface, so include the
> necessary context to help us understand the problem. I ended up having
> to go back and read all your earlier messages in the thread to work out
> what the problem is that you were having. People, including me, may not
> always feel like spending that much time to answer a question, so please
> help us to help you.
>
> If I understand correctly, you want to have control over error message
> presentaiton.
>
> [... snip...]
>
> > [field.html]
> > <tr{% if field.errors %} class="errors" {% endif%}>
> >   <th>
> >     <label for="id_{{ field.name }}">{{ field.label }}{% if
> > field.field.required %}<span class="required">*</span>{% endif %}:</
> > label>
> >   </th>
> >   <td>
> >     {{ field }}
> >     {% if field.errors %}{{ field.errors }}{% endif %}
>
> So this is the problem. If you look at field classes (in
> newforms.fields), you can see that the errors attribute is a
> newforms.util.ErrorList class and the __str__ method for ErrorList is
> the as_ul() method -- displaying results as an unordered list.
>
> If you want to control the presentation, you will need to iterate over
> field.errors and write out the results one by one. Or you could write a
> filter that applies to field.error and does this for you. Remember that
> ErrorList is a subclass of Python's standard lists, so something like
> (untested):
>
>         {% if field.errors %}
>            {% for error in field.errors %}
>               {{ error }}<br />
>            {% endfor %}
>         {% endif %}
>
> This particular example would just dump the strings with br tags between
> them, but you can obviously do whatever you want there.
>
> Some experimentation will be required, but since you have full access to
> the raw error strings, anything should be possible.
>
> Regards,
> Malcolm
>
> --
> Works better when plugged in.http://www.pointy-stick.com/blog/
Hi,
Sorry for that, I didn't know you received this by e-mail, I just come
here kind of like a forum... Won't happen again.

Thanks for your help, I managed to work this out by using the usual
forms and not that TemplatedForm I was using before.
In the template I just put:
{%if field.errors%}<td><span class="highlight"><b>{% for error in
field.errors %}    {{ error }}{%endfor%}</b></span></td>{%endif%}
This just prints the error as simple text exactly where I want it to
appear.
It was so simple after all... :)
Thanks for your help and sorry for all the trouble.

Ana


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to