1👍
✅
why not to use getattr/hasattr calls? You can write something like this:
full_attr_name = 'image_' + attr_name
if hasattr(self, full_attr_name):
getattr(self, full_attr_name).save(filename, suf, save=False)
Hope, you have caught the idea.
0👍
If your having images of different sizes then I think using sorl-thumbnail would have been a better approach. Link attached.
http://sorl-thumbnail.readthedocs.org/en/latest/examples.html#model-examples
👤Anup
- [Answer]-How to convert sql join into django
- [Answer]-Django: Write a Create/Update template for a model with a ManyToMany-Through relationship
- [Answer]-Django-Haystack autoquery gives strange results with solr backend
- [Answer]-Django website 400 error from a client on Mac, Chrome/Firefox
- [Answer]-Cannot receive POST request from Instagram API
Source:stackexchange.com