Hello-
So I have the following issue and have not been able to find a
solution to it anywhere! I have the following ModelForm object:
class OptionForm(ModelForm):
class Meta:
model = Option
based on the following Option object:
class Option(models.Model):
stem = models.ForeignKey(Stem, null=True, blank=True)
label = models.CharField(max_length=500)
value = models.CharField(max_length=255)
Now, in views.py I return the following when I request the form:
option_db = Options.object.get(id=1)
option = OptionForm(instance=option_db)
return render_to_response('create_edit_option.html',
{'option':option})
Everything works great, as expected, on post all data is bound
correctly and when form is initially displayed all the information
from the database initially part of the OptionForm object is displayed
correctly. My problem is that there are many instances where, within
the template, I want to access the inital value in "label", for
example. If I do {{ option.label }} I get the string "<input
type="text"..." etc, as documented, BUT say the label for option with
id=1 is "Option One!", then {{ option.label }} prints <input
type="text" name="whatever" value="OptionOne!"/>, but I just want the
string "Option One!". Same thing for a select box. Is this
possible??
Thanks!
Clea
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---