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

Frontend error #151

Closed crisfcodes closed 4 years ago

crisfcodes commented 4 years ago

Error

I try to access the cropped image in the frontend but it throws up the following error:

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 3.0.7
Exception Type: AttributeError
Exception Value: 'str' object has no attribute '_meta'

Model

class Banner(models.Model):
    """Main banner image of the page."""

    image = models.ImageField(blank=True, null=True, upload_to="banners")
    cropping = ImageRatioField("image", "800x360")
    title = models.CharField("Tittle", max_length=68)

    class Meta:
        verbose_name = "Banner"
        verbose_name_plural = "Banners"
        ordering = ["created"]

    def __str__(self):
        return self.title

Frontend

<img src="{% cropped_thumbnail Banner "cropping" %}" alt="{{ image }}">