我希望在django管理界面之外使用django-image-cropping。里面正在工作。我也可以得到django-image-cropping的示例。但这只是没有显示正确的小部件。为什么?
# ...
class Person(TranslatableModel):
# ...
pic = ImageCropField(_("profile picture"),
blank=True,
null=True,
upload_to=settings.USER_PICTURE_DIR,
)
picture_cropped = ImageRatioField(
'pic',
'{}x{}'.format(*settings.USER_PICTURE_SIZE)
)
# ...
# ...
class PersonUpdateForm(ModelForm):
# ...
class Meta:
model = Person
fields = [
'pic',
'picture_cropped',
]
# ...
class PersonUpdateView(LoginRequiredMixin, OnlySelfMixin, UpdateView):
model = Person
template_name = 'persons/person_intern_form.html'
form_class = PersonUpdateForm
# ...
{% extends 'intern/intern_base.html' %}
{% load i18n sekizai_tags %}
{% block main_content %}
<form action="{{ action }}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save"/>
</form>
{% endblock main_content %}
{% addtoblock "css" %}
{{ form.media.css }}
{% endaddtoblock %}
{% addtoblock "js" %}
{{ form.media.js }}
{% endaddtoblock %}
答案 0 :(得分:0)
这里有两个问题: