Django-croppie is an application for easy integration croppie.js image cropper to django projects.
Install with pip install django-croppie
Add croppie
to INSTALLED_APPS
:
INSTALLED_APPS = [
...
'croppie',
...
]
from croppie.fields import CroppieField
class AddForm(forms.Form):
photo = CroppieField()
Also CroppieField
takes non required argument options
- a python dictionary that represent croppie.js
settings. For example:
photo = CroppieField(
options={
'viewport': {
'width': 120,
'height': 140,
},
'boundary': {
'width': 200,
'height': 220,
},
'showZoomer': True,
},
)
{% block js %}
{{ form.media }}
{% endblock js %}
<div class="row">
<div id="cropper"></div>
</div>
There is an example project in the example
directory. Read README.md
for deploy instructions.