-
Notifications
You must be signed in to change notification settings - Fork 276
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
Integration with django-parler package #570
Comments
I tried something in @receiver(post_save, sender=Slider)
def save_image(sender, instance, created, **kwargs):
translations = instance.translations.all()
for translation in translations:
translation.image_medium.url
translation.image_large.url In this case images are being saved sometimes. |
The first variant is probably not working because the ImageSpecFields are not columns in the DB (I'm speculating here). Based on your feedback we can investigate if this is some bug in django-imagekit or is something specific to django-parler and how the integration with it should happen. Please share more details (like traceback) or what exactly you mean by "None of them worked." |
I meant both variants didn't work, and I am not getting any error.
serializers.py class SliderSerializer(TranslatedSerializerMixin, TranslatableModelSerializer):
translations = TranslatedFieldsField()
image_large = serializers.SerializerMethodField()
image_medium = serializers.SerializerMethodField()
class Meta:
model = Slider
fields = [
"id",
"translations",
"image_large",
"image_medium",
]
def get_image_large(self, obj):
lang = obj.get_current_language()
translation = obj.translations.get(language_code=lang)
return translation.image_large.url
def get_image_medium(self, obj):
lang = obj.get_current_language()
translation = obj.translations.get(language_code=lang)
return translation.image_medium.url In this case when request to api, it returns images without any problem. |
This is how django-imagekit is designed to work when Now based on that and your findings can we assume that there is no issue and we can close it? |
Yes I understand that, but in normal use when object saved it generates image and also saves image, it appears in media folder, and also I was able to use it as object atrtribute to get image, serializer also knows it as field.
It is working, but I don't think it is the good way to make it work, in serializer images should come inside |
Sorry for that but currently I'm mostly reviewing PRs and releasing new versions. I don't have the free time to debug issues for others. If you can propose better integration with django-parler I'll be happy to review and merge. |
I have multilanguage app, and I need to use multiple images in different languages, I am using
django-parler
for that, butdjango-imagekit
is generating images.models.py
I've tried another option like:
None of them worked.
Is it possible to use it with
django-parler
?The text was updated successfully, but these errors were encountered: