Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Created June 1, 2018 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CITGuru/7b23863c6b4b97c9177219418442c4da to your computer and use it in GitHub Desktop.
Save CITGuru/7b23863c6b4b97c9177219418442c4da to your computer and use it in GitHub Desktop.
from django.forms import ModelForm
from .models import Bin
from cloudinary.forms import CloudinaryFileField, CloudinaryJsFileField
class ServerUploadBinForm(ModelForm):
class Meta:
model = Bin
# To add some options, tags, transformations to your cloudinary image upload
class ServerUploadBinFormWithOptions(ModelForm):
class Meta:
model = Bin
image = CloudinaryFileField(
attrs={'style': "margin-top: 30px"},
options={
'tags': "directly_uploaded",
'crop': 'limit', 'width': 1000, 'height': 1000,
'eager': [{'crop': 'fill', 'width': 150, 'height': 100}]
}
)
class DirectUploadBinForm(ModelForm):
class Meta:
model = Bin
image = CloudinaryJsFileField()
# To add some options, tags, transformations to your cloudinary image upload
class DirectUploadBinFormWithOptions(ModelForm):
class Meta:
model = Bin
image = CloudinaryJsFileField(
attrs={'style': "margin-top: 30px"},
options={
'tags': "directly_uploaded",
'crop': 'limit', 'width': 1000, 'height': 1000,
'eager' [{'crop': 'fill', 'width': 150, 'height': 100}]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment