Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Daniel Roseman

On May 13, 12:47 pm, Miguel  wrote:
> the problem I have is that the fields are dynamic so I can not do any model
> from a form django object...
>
> Miguel
> Sent from Madrid, Spain
>

This doesn't follow. Forms don't have to be based on models, and it's
perfectly possible to do a dynamic form. All you have to do is
override the __init__ function on the form and manipulate self.fields.
--
DR.
--~--~-~--~~~---~--~~
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: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Thierry

I was able to get the user input back if there are errors but I have a
customized form class which extends the UserCreationForm.  I was
following the example at:

http://www.djangobook.com/en/2.0/chapter14/#cn176

You will notice that if the user inputs are not valid, the view re-
initialize the form object to:

form = UserCreationForm(request.POST)

The above is sent back to the template.  My template looks like the
following and it carries over the user inputs:

Username:
{{ form.username }}

The form documentation is http://docs.djangoproject.com/en/dev/topics/forms/
I am not sure if you have a customized form class yet but that's how I
would have done it for validation of many input fields.

On May 13, 7:47 am, Miguel  wrote:
> the problem I have is that the fields are dynamic so I can not do any model
> from a form django object...
>
> Miguel
> Sent from Madrid, Spain
>
> On Wed, May 13, 2009 at 1:27 PM, Miguel  wrote:
> > ignorance, I guess. Django is a really huge framework and I am new using
> > it.:-s
>
> > Where can I find documentation about how python handle this?
>
> > Miguel
> > Sent from Madrid, Spain
>
> > On Wed, May 13, 2009 at 1:24 PM, Daniel Roseman <
> > roseman.dan...@googlemail.com> wrote:
>
> >> On May 13, 11:59 am, Miguel  wrote:
> >> > I want to generate the following info in my html:
>
> >> >  >>  value='dynamic
> >> > value' >
>
> >> > To do that I proccess the info as follows:
>
> >> >                                         Peso (kg)
> >> >                                         {% ifequal fila.__str__
> >> > metodo.get_unidad_series %}
> >> >                                             {% for serie in
> >> > metodo.get_rango_series_mod_10 %}
> >> >                                                 
>
> >> >                                                      >> > class='celda_activa'
> >> > name='peso_{{embebido.id}}_{{ciclo}}_{{fila|get_numero_serie:serie}}'
>
> >> >                                                     {% for evaluacion in
> >> > embebido.get_evaluaciones %}
> >> >                                                         {% ifequal
> >> > serie.__str__ evaluacion.serie.__str__ %}
> >> >                                                             {% ifequal
> >> > ciclo.__str__ evaluacion.ciclo.__str__ %}
>
> >> > value="{{evaluacion.peso}}"
> >> >                                                             {%
> >> endifequal %}
> >> >                                                         {% endifequal%}
> >> >                                                     {% endfor %}
> >> >                                                     {% ifequal accion
> >> "ver"
> >> > %} readonly='readonly'{% endifequal %}
>
> >> >                                                 
> >> >                                             {% endfor %}
>
> >> > when errors occur, the users is sent to the same page but, I want to
> >> fill
> >> > the values the user has already filled. I have these variables names and
> >> > values in the context but how can I replace them if the html inputs are
> >> > dynamic names?
>
> >> > could anybody help me with these? I am a little lost.
>
> >> > Thank you in advance,
>
> >> > Miguel
> >> > Sent from Madrid, Spain
>
> >> As I said on the original thread, the Django forms framework handles
> >> this for you automatically. Is there a reason why you have chosen not
> >> to use it?
> >> --
> >> DR.
--~--~-~--~~~---~--~~
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: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Miguel
the problem I have is that the fields are dynamic so I can not do any model
from a form django object...

Miguel
Sent from Madrid, Spain

On Wed, May 13, 2009 at 1:27 PM, Miguel  wrote:

> ignorance, I guess. Django is a really huge framework and I am new using
> it.:-s
>
> Where can I find documentation about how python handle this?
>
>
>
> Miguel
> Sent from Madrid, Spain
>
> On Wed, May 13, 2009 at 1:24 PM, Daniel Roseman <
> roseman.dan...@googlemail.com> wrote:
>
>>
>> On May 13, 11:59 am, Miguel  wrote:
>> > I want to generate the following info in my html:
>> >
>> > >  value='dynamic
>> > value' >
>> >
>> > To do that I proccess the info as follows:
>> >
>> > Peso (kg)
>> > {% ifequal fila.__str__
>> > metodo.get_unidad_series %}
>> > {% for serie in
>> > metodo.get_rango_series_mod_10 %}
>> > 
>> >
>> > > > class='celda_activa'
>> > name='peso_{{embebido.id}}_{{ciclo}}_{{fila|get_numero_serie:serie}}'
>> >
>> > {% for evaluacion in
>> > embebido.get_evaluaciones %}
>> > {% ifequal
>> > serie.__str__ evaluacion.serie.__str__ %}
>> > {% ifequal
>> > ciclo.__str__ evaluacion.ciclo.__str__ %}
>> >
>> > value="{{evaluacion.peso}}"
>> > {%
>> endifequal %}
>> > {% endifequal%}
>> > {% endfor %}
>> > {% ifequal accion
>> "ver"
>> > %} readonly='readonly'{% endifequal %}
>> > >
>> > 
>> > {% endfor %}
>> >
>> > when errors occur, the users is sent to the same page but, I want to
>> fill
>> > the values the user has already filled. I have these variables names and
>> > values in the context but how can I replace them if the html inputs are
>> > dynamic names?
>> >
>> > could anybody help me with these? I am a little lost.
>> >
>> > Thank you in advance,
>> >
>> > Miguel
>> > Sent from Madrid, Spain
>>
>> As I said on the original thread, the Django forms framework handles
>> this for you automatically. Is there a reason why you have chosen not
>> to use it?
>> --
>> DR.
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Miguel
ignorance, I guess. Django is a really huge framework and I am new using
it.:-s

Where can I find documentation about how python handle this?



Miguel
Sent from Madrid, Spain

On Wed, May 13, 2009 at 1:24 PM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On May 13, 11:59 am, Miguel  wrote:
> > I want to generate the following info in my html:
> >
> >   value='dynamic
> > value' >
> >
> > To do that I proccess the info as follows:
> >
> > Peso (kg)
> > {% ifequal fila.__str__
> > metodo.get_unidad_series %}
> > {% for serie in
> > metodo.get_rango_series_mod_10 %}
> > 
> >
> >  > class='celda_activa'
> > name='peso_{{embebido.id}}_{{ciclo}}_{{fila|get_numero_serie:serie}}'
> >
> > {% for evaluacion in
> > embebido.get_evaluaciones %}
> > {% ifequal
> > serie.__str__ evaluacion.serie.__str__ %}
> > {% ifequal
> > ciclo.__str__ evaluacion.ciclo.__str__ %}
> >
> > value="{{evaluacion.peso}}"
> > {% endifequal
> %}
> > {% endifequal%}
> > {% endfor %}
> > {% ifequal accion
> "ver"
> > %} readonly='readonly'{% endifequal %}
> > >
> > 
> > {% endfor %}
> >
> > when errors occur, the users is sent to the same page but, I want to fill
> > the values the user has already filled. I have these variables names and
> > values in the context but how can I replace them if the html inputs are
> > dynamic names?
> >
> > could anybody help me with these? I am a little lost.
> >
> > Thank you in advance,
> >
> > Miguel
> > Sent from Madrid, Spain
>
> As I said on the original thread, the Django forms framework handles
> this for you automatically. Is there a reason why you have chosen not
> to use it?
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
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: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Daniel Roseman

On May 13, 11:59 am, Miguel  wrote:
> I want to generate the following info in my html:
>
> 
>
> To do that I proccess the info as follows:
>
>                                         Peso (kg)
>                                         {% ifequal fila.__str__
> metodo.get_unidad_series %}
>                                             {% for serie in
> metodo.get_rango_series_mod_10 %}
>                                                 
>
>                                                      class='celda_activa'
> name='peso_{{embebido.id}}_{{ciclo}}_{{fila|get_numero_serie:serie}}'
>
>                                                     {% for evaluacion in
> embebido.get_evaluaciones %}
>                                                         {% ifequal
> serie.__str__ evaluacion.serie.__str__ %}
>                                                             {% ifequal
> ciclo.__str__ evaluacion.ciclo.__str__ %}
>
> value="{{evaluacion.peso}}"
>                                                             {% endifequal %}
>                                                         {% endifequal%}
>                                                     {% endfor %}
>                                                     {% ifequal accion "ver"
> %} readonly='readonly'{% endifequal %}
>                                                     >
>                                                 
>                                             {% endfor %}
>
> when errors occur, the users is sent to the same page but, I want to fill
> the values the user has already filled. I have these variables names and
> values in the context but how can I replace them if the html inputs are
> dynamic names?
>
> could anybody help me with these? I am a little lost.
>
> Thank you in advance,
>
> Miguel
> Sent from Madrid, Spain

As I said on the original thread, the Django forms framework handles
this for you automatically. Is there a reason why you have chosen not
to use it?
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---