question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MULTITENANT_RELATIVE_MEDIA_ROOT not working properly

See original GitHub issue

When i upload file, it’s working fine but, when i try to preview the file after clicking the link i’m getting 404 error. Here is my configurations

STATICFILES_STORAGE = "django_tenants.staticfiles.storage.TenantStaticFilesStorage"
MULTITENANT_RELATIVE_STATIC_ROOT = ""  # (default: create sub-directory for each tenant)


DEFAULT_FILE_STORAGE = "django_tenants.files.storage.TenantFileSystemStorage"

MULTITENANT_RELATIVE_MEDIA_ROOT = ""  # (default: create sub-directory for each tenant)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
ArnWaccommented, Sep 7, 2020

I got the same problem. when you add "MULTITENANT_RELATIVE_MEDIA_ROOT = “” all files will be saved in “media/schema_name/file”, but the reference in the database is still “media/file”.

adding “%s” in MULTITENANT_RELATIVE_MEDIA_ROOT will fix it (for me)

Solution: "MULTITENANT_RELATIVE_MEDIA_ROOT = “%s”

0reactions
iamdarshan7commented, Oct 4, 2021

I had the same problem. And i solved by doing MULTITENANT_RELATIVE_MEDIA_ROOT = “%s” and in both main urls.py i.e for public and tenant main urls.py i added : if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) And suddenly it worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found