python - Use django sorl-thumbnail with django form-utils -


how implement sorl thumbnailing in django form utils?

so form utils documentation says imagewidget:

(thumbnails available if sorl-thumbnail installed; otherwise full-size image displayed).

however, can't seem implement it. tried using sorl's imagefield in models, breaks form-utils' imagewidget , can't head around using in template when have in template this:

<li class="field_upload">     {{ form.image.errors }}     <label for="id_image" class="top">{{  form.image.label }}</label>     {{ form.image }} </li> 

form utils has option says:

imagewidget accepts keyword argument, template. string defining how image thumbnail , file input widget rendered relative each other. template string should contain variable interpolation markers %(input)s , %(image)s. default value %(input)s
%(image)s

which in code looks this:

pic = forms.imagefield(     widget=imagewidget(template='%(image)s<br />%(input)s')) 

but can't still figure out.

it looks in form class definition naming imagefield pic, in template attempting refer field form.image.

try using standard django form renderer putting {{form}} in template--if works know it's problem templating.


sorl thumbnail library should need accessible on django project's python path (along python image library).

to check see whether or not these libraries available django project, goto project's root directory , run...

$ python manage.py shell >> import sorl.thumbnail >> import pil 

if neither of imports throw importerrors installed.


also, maybe include more code, entire form have defined in forms.py.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -