I have a model with an ImageField and would like to add some image
processing using PIL. Problem is that i don't know how to do this
best.
My approach would be to do it in the view function (indicated below
with "Processing here?"); some concrete questions:
- How can i best reuse code to do the same thing from admin?
- Can i do the processing also from the overloaded save method in the
model? I thought no because i don't have the UploadedFile object there
any more?
- I wanted to make it efficient so since i have an
InMemoryUploadedFile object here, i would like to feed the in memory
data to a PIL image; how to do this?
Thanks for any direction,
Paul
PS: I did read a lot already on google but found no consistent
direction on this.....
class rusk(models.Model):
image = models.ImageField(upload_to='uploadedImages')
class RuskForm(ModelForm):
class Meta:
model = rusk
fields = ('image')
def add(request):
if request.method == 'POST':
form = RuskForm(request.POST, request.FILES)
if form.is_valid():
---> Processing here?
rusk = form.save(commit=False)
rusk.save() #Hier pas wordt
return HttpResponseRedirect('/latest')
else:
form = RuskForm()
return render_to_response('add.html', {'form': form,},
context_instance=RequestContext(request))
--
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.