-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django import template | ||
from django.conf import settings | ||
from django.core.files.storage import FileSystemStorage, get_storage_class | ||
|
||
register = template.Library() | ||
|
||
StorageClass = get_storage_class() | ||
|
||
|
||
@register.filter(is_safe=True) | ||
def media_full_path(path): | ||
# TODO: Refactor http and https | ||
if StorageClass == FileSystemStorage: | ||
if settings.DEBUG: | ||
return f"http://serve:8000{path}" # Don't use this in production | ||
return f"https://{settings.BASE_URL}{path}" | ||
return path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters