Hi --

I'm creating a FormSet and want to include some data in the form output
that is not an html input element.

Some of the data I pass to the FormSet, which gets passed to the form, I
just want to display, I don't want to put it into an HTML input
element.  I want it to be available in the template.  Here is what I
tried, which doesn't work:


class SectionForm(forms.Form):
    section_id = forms.IntegerField(label='Section ID:', required=False,
widget=forms.HiddenInput())
    section_title = forms.CharField(label='Title', required=True)
    section_text = forms.CharField(label='', widget=forms.Textarea,
required=True)
  
    def __init__(self, data=None, auto_id='id_%s', prefix=None,
initial=None, empty_permitted=False):
        super (SectionForm, self).__init__(data, auto_id, prefix,
initial, empty_permitted)
       
        # This is what I want to do, more or less, but it won't work
(TypeError: unscriptable object)
        #self.s3_audio_file = initial['s3_audio_file']


In the template, I want to display s3_audio_file, but I don't need or
want it to be editable.  It's for information only.  Just text, or
html-formatted text.

{{ form.s3_audio_file }}

Is there some way to have the form contain arbitrary data that I pass to
it with the "initial" dictionary?
Perhaps, I have to create a faux Widget and Custom field?  That seems
like a long way around for something that should be simple.

Thanks in advance for any help.

Best,
Liam


Also, I was unsure about what to do with empty_permitted -- I got an
error before I added it to the  super() call.






--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to