Monday, July 23, 2012

Re: Image Cropping in template form

Hi Patrick,

Did you find any solution to this issue ? I'm facing exactly the same problem... The widget is imported and assigned to the field without any error, but on rendering it works like a basic textfield. 

The markup look like the field is initially rendered correctly in HTML, but then the mandatory JavaScript code (jcrop, image_cropping.js & co) is not loaded executed here. At least that's what a quick comparison between the rendering of the Admin and the my frontend code shows.

Thanks in advance,

Nicolas

Le mercredi 4 avril 2012 23:16:34 UTC+2, Patrick Sweet a écrit :
Hi folks, I'm hoping someone can help me with this. I can't get the image_cropping widget to work in my template.

I've installed django-image-cropping ( https://github.com/jonasundderwolf/django-image-cropping ) and have set up my models appropriately. It works absolutely perfect in the admin, but I can't seem to get it to work with a front-end form in a template.

Digging around for information, I've tried to import image_cropping.widgets and assign the ImageCropWidget to the cropping field, but the form field still shows up as a text input.

FROM Forms.py:

class ProfileForm(forms.ModelForm):
class Meta:
        model = Candidate
        exclude = ('user')
        widgets = {
            'cropping': ImageCropWidget(),
        }

And in my template, I'm calling the form field directly, not "as_p" or "as_table."
FROM form.html:
<div class="bio_field_wrapper">
{{ Form.cropping.errors }}
{{ Form.cropping }}
</div>


Any help would be greatly appreciated.

- Pat

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/czAi5KRFOfoJ.
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