Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CloudinaryField when blank=True #82

Closed
wants to merge 1 commit into from
Closed

Fixed CloudinaryField when blank=True #82

wants to merge 1 commit into from

Conversation

michaelgodshall
Copy link

Fix for #81

@tocker
Copy link
Contributor

tocker commented Nov 23, 2016

Hi @godshall ,

Thanks for submitting this pull request!

Unfortunately this solves the symptom but not the problem. The error occurs because python is testing for Truth using len() which is defined as len(self.public_id). When public_id is None the error is raised.

Furthermore value is None seems to be standard for from_db_value (see official doc).

I'm pushing soon a more comprehensive solution that would support None values in the CloudinaryField.

@michaelgodshall
Copy link
Author

Hi @tocker,

Thanks for your feedback!

Regarding the doc you linked, you should only need to handle the None case if the field allows null=True. I assumed that CloudinaryField does not allow null=True since its internal type is CharField, and it is recommended to avoid using null on Charfields (see null docs). The previous versions of pycloudinary used the same approach.

If CloudinaryField really needs to handle the None case, then parse_cloudinary_resource will probably need to check if not value to handle the empty string properly.

@iMerica
Copy link

iMerica commented Jan 29, 2017

LGTM. This bug is a showstopper for me on Django 1.9 so the only way I'm able to use Pycloudinary is on my personal fork.

Doing something as basic as this results in Object of type 'NoneType' has no len() error

class Foo(models.Model):
  field = CloudinaryField('image', blank=True)

x = Foo.objects.create()

@richgieg
Copy link

richgieg commented Feb 7, 2017

Hi @godshall and @iMerica,

Version 1.6 of Pycloudinary was recently released, containing a fix for this issue. Is it working okay for you?

@michaelgodshall
Copy link
Author

@richgieg I installed 1.6 last week and it seems to be working great. Thanks for the follow-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants