On Sep 17, 12:31 pm, TKa <[EMAIL PROTECTED]> wrote: > Can anybody help me how to create dynamic images within Django? > Drawing the image with Python is not a problem but how to link the > created image to the httpResponse? > > Because I need input from the Django models for the image I want to > call the drawing function from the view. I guess I could save the > image file to temporary folder and then link the image tag to that > file in Response but is there any better way to do it? This way I > would generate a lot of temporary image files and load the file-system > for nothing plus I would need a method to clean up the files > afterwards. > > Thanks, > Tommi
An HttpResponse is a 'file-like object', which means you can call .write() on it just as if it was a real file. I would have one view creating the image, and one view producing the HTML page which refers to the image in an img tag via the image view's URL. for example: in the urlconf: url(r'my_image/(?P<my_param>\w+?)/', 'myview.image', name='image_view'), url(r'my_view/(?P<my_param>\w+?)/', 'myview.view', name='html_view'), and in the template: <img src='{% url image_view my_param %}' alt='whatever'> -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---