jonasundderwolf / django-image-cropping

Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.
Other
553 stars 130 forks source link

Using Image Cropping With User (not just in Admin) does not work. #90

Closed gabe-dol closed 8 years ago

gabe-dol commented 8 years ago

I do everything as the doc says. Then I do {{ form.media }} in the head and {{ form }} in the body. The file upload works just fine, but the user cannot see the image in order to crop it! How do i fix this?

lomholdt commented 8 years ago

Are you including the 'cropping' area in your form? The plugin does not change the upload field (as i thought to begin with), you have to add the cropping field to your template.

bernardojedi commented 8 years ago

I am having the same issue here, I noticed that my {{ form.media }} is not rendering to anything. I have tried using the ImageCropWidget on both ImageCropField and ImageRatioField. @lomholdt Can you elaborate your solution?

lomholdt commented 8 years ago

So I added the widget to my moddel as such:

logo = models.ImageField(blank=True, null=True, upload_to=logo_path)
cropping_logo = ImageRatioField('logo', '200x200', size_warning=True)

In my template i add the form media at the top with {{ form.media }}, and I add the image field and cropping field like this:

 {{ form.logo }}
 {{ form.cropping_logo }}

When I do this, It works :) Did you remember to add the 'image_cropping' and 'easy_thumbnails' apps to the INSTALLED_APPS in settings.py?

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    ...
    'image_cropping',
    'easy_thumbnails',
]
gabe-dol commented 8 years ago

@lomholdt what is in your forms.py? Also you include {% load cropping %} and {% load easy_thumbnails %} in your template right? This is what I get when I try what u did

http://imgur.com/a/BVFj8

Clearly not the right stuff haha

lomholdt commented 8 years ago

I only include {% load cropping %} because I am only using the {% cropped thumbnail ... %} tag. In my form I have

class MyEditForm(forms.ModelForm):

    class Meta:

        model = ModelName
        fields = ['name',
                  'email',
                  ...
                  'logo',
                  'cropping_logo',
                  ]

        widgets = {
            'logo': ImageCropWidget,
        }
gabe-dol commented 8 years ago

@lomholdt Yeah IDK what exactly is causing my issue. I'm on on python 3.4, django 1.8. Currently I am just using a profile pic that doesnt crop, but re-sizes the uploaded image, and it seems to work fine. thanks