Skip to content
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

ImageField: not loading when developping locally #62

Open
dannywillems opened this issue Mar 3, 2024 · 3 comments
Open

ImageField: not loading when developping locally #62

dannywillems opened this issue Mar 3, 2024 · 3 comments

Comments

@dannywillems
Copy link

See #5 (comment)

@WhyNotHugo
Copy link
Owner

Can you share an example of the template?

@dannywillems
Copy link
Author

dannywillems commented Mar 3, 2024

Take this as an example: https://stackoverflow.com/questions/45865205/imagefield-django-template, modulo the changes suggested in the answer.
Let me know if you want a full example.

@Alurith
Copy link

Alurith commented Mar 19, 2024

I don't know if this can be a good solution but I had the same issue while serving statics locally, so I overrided the url_fetcher to fix it.

def url_fetcher(self, url):
    if "file://" in url:
        file_path = url.replace("file://", "", 1)
        if file_path:
            url = f"{self.request.scheme}://{self.request.get_host()}{file_path}"

    return super().url_fetcher(url)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants