Git Product home page Git Product logo

Comments (5)

respondcreate avatar respondcreate commented on August 16, 2024

Hey @rocjojo

I'm a bit confused by your ticket. You said 'When i use the standard ImageField in my serializers, the full url is displayed, everything works fine'...would you mind responding with the output from 'the standard ImageField' serializer and how it differs from what you're expecting the VersatileImageFieldSerializer to output?

from django-versatileimagefield.

rocjojo avatar rocjojo commented on August 16, 2024

Hey,

My problem is, as soon i use the VersatileImageFieldSerializer in my ModelSerializer, the urls become absolute in the json response.

Output of the logo field from the serializer without declaring the VersatileImageFieldSerializer in the Serializer :

In [7]: print ser.ShopSerializer(shop).data['logo']
/media/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4

GET request gives

"logo":"http://192.168.99.100:3001/media/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4"

Output of the logo field from the serializer with the VersatileImageFieldSerializer

logo = VersatileImageFieldSerializer(
    sizes=[
        ('full_size', 'url'),
        ('thumbnail', 'thumbnail__100x100'),
        ('medium_square_crop', 'crop__400x400'),
        ('small_square_crop', 'crop__50x50')
    ]
)

In [5]: print ser.ShopSerializer(shop).data['logo']
{'medium_square_crop': '/media/__sized__/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-    f43b10c778a4-crop-c0-5__0-5-400x400.jpg', 'small_square_crop': '/media/__sized__/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4-crop-c0-5__0-5-50x50.jpg', 'full_size': '/media/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4', 'thumbnail': '/media/__sized__/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4-thumbnail-100x100.jpg'}

GET request gives

"logo":{"medium_square_crop":"/media/__sized__/shop/VS/1890/fff/e3f27044-09f8-45bd-89b8-f43b10c778a4-crop-c0-5__0-5-400x400.jpg","small_square_cr

As you can see, the "http://192.168.99.100:3001" part disappeared.

Thank again for your help.

from django-versatileimagefield.

respondcreate avatar respondcreate commented on August 16, 2024

@rocjojo

Ahhhh, I see what's happening now. I'm working on the fix right now and will let you know when it's patched!

from django-versatileimagefield.

respondcreate avatar respondcreate commented on August 16, 2024

Hey @rocjojo !

The fix for this is available in the 1.0.6 release which I just uploaded to PyPI. Get it via pip:

$ pip install django-versatileimagefield==1.0.6

Thanks for contributing to django-versatileimagefield! :)

from django-versatileimagefield.

rocjojo avatar rocjojo commented on August 16, 2024

Yeah it works !

Glad to contribute to your project, thanks for your quick patch :)

from django-versatileimagefield.

Related Issues (20)

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.