dima-kov / django-croppie Goto Github PK
View Code? Open in Web Editor NEWDjango application for croppie.js integration
License: MIT License
Django application for croppie.js integration
License: MIT License
Hi ! i am using croppie and its working fine. I was trying to add some functionality like clicking on a button gives me the cropped image [working fine] but i also wanted to add a button which takes be back to crop the same uploaded image. is there a way to render croppie again without actually refreshing the page.
ThankYou. ;)
When a form has an error. ie form is invalid, the image selected is reset and user has to re upload the image,
options={
'viewport': {'width': 210, 'height': 210, 'type': 'circle'},
'boundary': {'width': '100%', 'height': 300},
'showZoomer': True,
'quality': '.5'
}
This code can't set quality.
image = models.ImageField(default='default.jpg', upload_to='profile_pics')
as you can see i need to set a default image and the location how to do this with:
photo = CroppieField()
By just adding to the example template file in the repo croppie does not get rendered.
cómo se pueden mostrar la imagenes en las plantillas en forma de circulo
I'm trying to use the module with an inlineformset_factory, my settings are as as follow:
class Products(models.Model):
...
class Product_Image(models.Model):
product = models.ForeignKey('Products', on_delete=models.CASCADE)
image = models.ImageField(null=True, upload_to=...)
class ProductForm(forms.ModelForm):
...
class Product_ImageForm(forms.ModelForm):
image = CroppieField()
class Meta:
model = Product_Image
fields = '__all__'
ProductInlineFormSet = inlineformset_factory(Products, Product_Image,form=Product_ImageForm)
class NewProductView(LoginRequiredMixin, CreateView):
model = Products
form_class = ProductForm
template_name = 'products/addProduct.html'
login_url = reverse_lazy('users:login')
# fields = "__all__"
def get_context_data(self, **kwargs):
context = super(NewProductView, self).get_context_data(**kwargs)
if self.request.POST:
context['product_formset'] = ProductInlineFormSet(self.request.POST)
else:
context['product_formset'] = ProductInlineFormSet()
return context
...
...
{{product_formset}}
<div class="row">
<div class='col d-flex flex-row-reverse'>
<button class="btn btn-info btn-lg">Salvar</button>
<div>
</div>
<div style="width:50%">
<div id="cropper"></div>
</div>
</form>
{{ form.media }}
{{ product_formset.media }}
...
What I have when I open the page of the create view is a blank widget that wherever I upload an image does not update to crop the current image, like it would happen if it was in a normal form. I tried using a normal form and it worked perfectly but that is not my objective. It would be nice if in the future you added support to formsets and such.
I have a exception about django can't find a template - croppie/widget.html
1 | {% spaceless %}{% for widget in widget.subwidgets %}{% include widget.template_name %}****{% endfor %}{% endspaceless %}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.