Skip to content

Image fields' URLs aren't being correctly generated (prepended with 6 file://<home directory path>) #22

@arturmatos

Description

@arturmatos

I have a Django model with a ImageField, and I'm trying to use PDFTemplateView to generate a PDF that includes that image. However, the image URL isn't being properly generated in the PDF. If I put something like this in my template:

{{ user.get_profile.company.logo.url }}

This gets properly converted if I request it in HTML (with ?as=html):

/media/logos/abcfinancialservices.png

But if I'm generating the PDF I get this instead:

file:///Users/amatosfile:///Users/amatosfile:///Users/amatosfile:///Users/amatosfile:///Users/amatos/media/logos/abcfinancialservices.png

So basically I'm getting my home directory prepended 6 times in the URL.

I haven't had more time to look into it, but it looks like a bug. Or I'm doing anything wrong?

I'm not that familiar with Django, but assuming it's a bug I'm happy to submit a patch if I can get some guidance -I just need some brief explanation of what the problem might be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions