of the image?
I am storing my URLs to images in a charField, but I am letting the
user interact with the imageField. Everything works fine to render the
imageField and I can use the imageField to upload an image. The url of
the stored image is safely stored in the database in a charField. The
only problem is I can't figure out how to pass the image url to the
imageField when I dynamicly create the imageField.
Is there a way to bind the data from the charField to the imageField.
I looked through all the data binding documentation and it doesnt show
how to bind data on a per field basis.
Any suggestions would help. The reason I have the url in a charField
is because its a property in a sudo triplestore.
Here is a sample of the code for my form.
class MetadataForm(ModelForm):
"""
Based upon the metatype create the correct field for this form.
"""
def __init__(self, *args, **kwargs):
super(MetadataForm, self).__init__(*args,**kwargs)
type_id = self.instance.metaType_id
if type_id != None:
self.fields['value'] = self.createField(type_id)
def createField(self,type):
metatype = MetaType.objects.get(id=type)
if (metatype.type == 'charField'):
return forms.CharField(widget = forms.Textarea,
required=False)
if (metatype.type == 'imageField'):
f = forms.ImageField(required=False)
return f
Thanks for the help,
Brian
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment