Image handling views

Base image handling Views

If not disabled, each image model need to have 3 views for uploading, fetching and cropping. User should subclass the following Class-based image handling base views for your custom image models.

class galleryfield.image_views.ImageCreateView(**kwargs)[source]

The Class-based view handling the saving of uploaded image.

target_model

When not set, defaults to garllery_widget.BuiltInGalleryImage

crop_url_name

When disable_server_side_crop is False, if None or an invalid URL name will raise an ImproperlyConfigured error.

disable_server_side_crop

Defaults to False

form_valid(form)[source]

User should override this method to save the object, for example, image model usually has a non-null user field, that should be handled here.

See the-save-method for detail.

See galleryfield.image_views.BuiltInImageCreateView for example.

class galleryfield.image_views.ImageListView(**kwargs)[source]

The Class-based view for fetching the existing images of the gallery instance.

target_model

When not set, defaults to garllery_widget.BuiltInGalleryImage

crop_url_name

When disable_server_side_crop is False, if None or an invalid URL name will raise an ImproperlyConfigured error.

disable_server_side_crop

Defaults to False

get_queryset()[source]

User need to override this method to do some basic filter in terms of who can see which images.

Returns

A Queryset

class galleryfield.image_views.ImageCropView(**kwargs)[source]

The Class-based view handling server side cropping of an image model instance.

target_model

When not set, defaults to garllery_widget.BuiltInGalleryImage

crop_url_name

When disable_server_side_crop is False, if None or an invalid URL name will raise an ImproperlyConfigured error.

disable_server_side_crop

Defaults to False

form_valid(form)[source]

Save the object from the form. This method should only be overridden when the model contains dynamic fields which need to be updated. For example, when there is a DateTimeField which records the updated datetime of the image.