Rocio Figueroa escribió: > 2008/3/26, Esteban Saavedra L. <[EMAIL PROTECTED]>: >> 2008/3/26, Rocio Figueroa <[EMAIL PROTECTED]>: >> >> > 2008/3/26, Esteban Saavedra L. <[EMAIL PROTECTED]>: >> > >> > > >> > > You could generate the form based on the model: >> > > >> > > UsuarioForm = forms.models.form_for_model(Usuario) >> > > >> > > And then customize each field both at the views and the template to >> > > put an order or special effect >> > > >> > >> > >> > howto i customize each field??? >> >> >> example: >> UsuarioForm.base_fields['nombre'].required = False >> >> in general >> >> UsuarioForm.base_fields['filed'].widget = type of widget > > > Thanks Esteban, I served much, and may make some changes to Form > > Now I have other question: howto fill values from one register to > fields, specifically when you want to edit an entry in the table, I > tried it with this: > > def edit(request, u_id): > usuario = Usuario.objects.get(id=u_id) > data = {'nombre': Usuario.nombre, > 'apellido': Usuario.apellido, > 'registro': Usuario.registro, > 'grupo': Usuario.grupo} > UsuarioForm = forms.models.form_for_model(Usuario) > form = UsuarioForm(data) > return render_to_response('usuario/usuarioEdit.html', {'form':form}) > > When viewing the template all fields are correctly except the related > field (group), the message in the form indicates that the value is not > valid for this type, the idea is that this flied shows the value for > the record that is trying edited. > > How can I solve this problem?
Hi Rocio, I am using: form_for_instance Your example will be: def edit(request, u_id): usuario = Usuario.objects.get(id=u_id) form = form_for_instance(usuario)() return render_to_response('usuario/usuarioEdit.html', {'form':form}) Greets Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---