Shawn, Ondrey, Thanks for your answers. I ended up using to ModelForm and ModelFormSet.
Cheers, Adrian On Tue, Jan 19, 2010 at 16:12, ondrey <ondrej.b...@gmail.com> wrote: > Hi, > > if the form is bound (i.e. form.is_bound is true) then you can access > its data attribute, which contains the data entered into the form. > If the form is valid (i.e. form.is_valid() is true), then you can > access the cleaned_data attributes as well. > > So for example if you have form like this: > f = MyForm({ "last_name": "some_value"}) > > you can access the value in template in this way > {{ f.data.last_name }} > > or alternatively, if your form is valid you can use: > {{ f.cleaned_data.last_name }} > > Just bear in mind, that the two values can be different since > cleaned_data the result of some processing in the validation methods. > > > hope it helps, > > -Ondrej Bohm > > On Jan 17, 7:35 pm, adrian_m <adrian.ma...@gmail.com> wrote: > > Hello people, > > > > How can I access the value of a form field in the template ? I'm > > having > > two different use cases : > > - display a field value as simple text (the field is not meant to be > > edited > > by the user, therefore i don't want to use a input field) > > - use the field value for generating a link > > ( something like this: <a href="{% url cmds.views.details > > form.cmd_id.value %}">Details</a> ) > > > > It would have been nice to have an attribute > > {{form.field_name.value}} > > which would return the value instead of a widget.Unfortunately there > > seems > > to be no such attribute available. > > > > I have looked at the Field attributes and also at the list of > > available widgets, > > but none seems to do what I need : simply display the value as raw > > text > > instead of generating input field / textarea / etc. I guess that my > > use cases > > are frequent enough, so there must be some simple way to do it ... > > > > (if it makes any difference: i am actually trying to use a forms set, > > and > > in each of the forms i want to create "details" and "delete" links > > using > > the id of the current record). > > > > Thanks in advance for any tips, > > Adrian > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- Adrian Maier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.