Hi,
i would like to use a ImageField...
I created a model with upload_to path like this:
class content_news_image(models.Model):
...
image = models.ImageField(upload_to='photos/')
...
I set the base path to settings.py like this:
MEDIA_ROOT = '/home/admin'
and use this manipulator :
class ContentManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
...
forms.ImageUploadField(field_name="r_image", is_required=True),
...
)
Follow view receive the POST:
...
...
if request.POST:
new_data = request.POST.copy()
new_data.update(request.FILES)
....
manipulator.save(new_data)
....
Now in new_data is a dictionary with name "r_image" which contains the
stuff of the image post (filename, content, content_type)...
But how can i save this? How the save() must look?
I have searched the documentation and a lot of postings here about
ImageField. I didn't found anything to save a ImageField from custom
manipulator...
i cannot imagine that i have to save the filename/path manuely like
follow, and write the content to a self made file.
def save(self, new_data):
obj = content_news_image(
image = new_data['r_image']['filename']
....
)
i would be very gratefull for answer!
thanks
pex
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---