Skip to main content

A django ImageField whose upload_to value is generated from the modal instance method get_upload_to

Project description

Django Dynamic Image

Description

A django ImageField whose upload_to value is generated from the modal instance method get_upload_to.

Installation

pip install django-dynamic-image

Usage

from django.db import models
from dynamic_image.fields import DynamicImageField

class ExampleModel(models.Model):
    name = models.CharField(max_length=56)
    image = DynamicImageField()

    def get_upload_to(self, field_name):
        class_name = self.__class__.__name__.lower()
        instance_name = self.name
        return "{}/{}".format(class_name, instance_name)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dynamic-image-1.1.1.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

django_dynamic_image-1.1.1-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page