Migrating from v2 to v3.

17 views
Skip to first unread message

Waldecir Santos

unread,
Jul 7, 2016, 11:28:44 AM7/7/16
to Django ImageKit
Hi all, 

Im migrating from django-imagekit v2 to v3, but I have some challenges, first I need to start using the older namer, I was able to do that following what we decided in this issue: https://github.com/matthewwithanm/django-imagekit/issues/373, I will move to the hasher namer once I can manually generate them all.

Now I need to have the same behaviour as django-imagekit v2, basically it shouldn't throw a an exception if file is missing and just render the url so it will return 404. I tried a custom Strategy, but not sure if it's a good approach.

+ class CustomJustInTime(object):
+     """
+     A strategy that ensures the file exists right before it's needed.
+     """
+
+     def on_existence_required(self, file):
+     │   try:
+     │   │   file.generate()
+     │   except:
+     │   │   pass
+
+     def on_content_required(self, file):
+     │   file.generate()
+
+     # def should_verify_existence(self, file):
+     #     return False
 

I need to use this because there is no way to have theses images in local development (We have around 350.000 images). 


Big Respect,
Waldecir
Reply all
Reply to author
Forward
0 new messages