Here is a working example. I am using svn version of Django, but IIRC
this works also in 1.0.
views.py:
from django.shortcuts import render_to_response
from django import forms
class Example(forms.Form):
field1 = forms.CharField()
field2 = forms.IntegerField(label='Labeled')
def view(request):
data = {'field1': 'Foo', 'field2': 10}
form = Example(data=data)
return render_to_response('t.html', {'form': form})
t.html:
{% for field in form %}
{{ field.label }}{{field.data}}
{% endfor %}
On Nov 23, 2:14 am, Richard Laager <[email protected]> wrote:
> On Sat, 2009-11-21 at 05:57 -0800, Anssi Kaariainen wrote:
> > If I am not completely mistaken you can use your ModelForm with
> > field.label and field.data to get read-only view of the model.
>
> I was trying to do something like this today and didn't have any luck.
> Do you have a pointer to a working sample?
>
> Richard
>
> signature.asc
> < 1KViewDownload
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=.