Git Product home page Git Product logo

django-croppable-images's People

Contributors

danxshap avatar djw avatar rclmenezes avatar theskumar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

django-croppable-images's Issues

How do you instantiate CroppableImageField in a form?

Also, quick question - I have a form like this:
class UserEditForm(forms.Form): first_name = forms.CharField(max_length=200, label="First Name") last_name = forms.CharField(max_length=200, label="Last Name") picture = CroppableImageField(required=False, label="Picture")

And I'm trying to instantiate it with this:
form = UserEditForm({'first_name': person.user.first_name, 'last_name': person.user.last_name, 'picture': (person.picture, person.picture_cropped) })

Do you happen to know what I'm doing wrong? Thanks!

Dumpdata only serializes filename

When using Django 1.5.5, I'm running into the issue where dumpdata is only outputting the filename of the CroppableImageField, without its coord_csv.

It seems that the best way to solve this is to use value_to_string():
https://docs.djangoproject.com/en/1.6/howto/custom-model-fields/#django.db.models.Field.value_to_string

Adding this to CroppableImageField seems to work for me:

def value_to_string(self, obj):
        if obj.picture:
            value = obj.picture.filename + IMAGE_FIELD_DELIMITER + obj.picture.coords_csv
        else:
            value = ''
        return self.get_prep_value(value)

Note that this doesn't solve loaddata...

Edit:
Found a way to make loaddata work! Overload get_db_prep_save():
https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#django.db.models.Field.get_db_prep_save

def get_db_prep_save(self, value, connection):
        return value.filename + IMAGE_FIELD_DELIMITER + value.coords_csv

Using CroppableImageField in ModelForms

Hey, we're trying to use django-croppable-images for our forms, but the readme is a little ambiguous on how to properly do this. Could you make an example in the readme or provide an example here?

This is what I'm doing currently:

models.py

from croppable.models import CroppableImageField
from croppable.utils import get_crop_processor

class Project(models.Model):

   image = CroppableImageField(
        invalidate_on_save=['project_page', 'preview_pitch'],
        upload_to="img/projectimage",
        blank=True)
    project_page = ImageSpec(
        get_crop_processor(image_field='image'),
        image_field='image')
    preview_pitch = ImageSpec(
        get_crop_processor(image_field='image'),
        image_field='image')

    ...

forms.py

from projects.models import Project
from croppable.forms import CroppableImageField

class MyModelForm(forms.ModelForm):

    class Meta:
        model = Project
        fields = ['image', 'title', 'content']

    image = CroppableImageField(blank=True)
    title = ...

When loading this form, all I get is the standard imagefield widget and it fails to save, with no issues or warnings, even with DEBUG = True.

If you can point me in the direction of this issue (I see there is another similar issue already opened) I'll be happy to fix and submit it.

jQuery 1.7 compatibility, bootstrap compatibility and admin page bug

Hi Dan-

I like your project.

However, I've been trying to use django-croppable-images for a project of mine and I've had a couple issues:

  • Without jQuery in the form media, cropped_image_admin.js breaks in the admin page. To fix this, I added a short:
    if (typeof($) == 'undefined') { jQuery = django.jQuery; $ = django.jQuery; }
  • I used Bootstrap and it's default CSS broke Jcrop's images. You can fix it if you add this to the jquery.Jcrop.css:
    .jcrop-holder img { max-width: none; vertical-align: none; }
  • Lastly, it's compliant with jQuery 1.4.2, but not with a newer version. I'm coming up with a few edits that will make it compatible with jQuery 1.7 (for example, jQuery 1.7 references HTML FileLists though the prop function and not the attr function).

I'm going to do what I can to make all these changes and pull request.

Cheers!

Broken with imagekit 3.0

I believe that imagekit made changes to how the cache is processed. When using the latest version, I get a can't pickle error when saving. Could it be the invalidate method on save?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.