-
Notifications
You must be signed in to change notification settings - Fork 9
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
MVJ-111 upload attachments to custom directory [RETRY] #814
base: develop
Are you sure you want to change the base?
MVJ-111 upload attachments to custom directory [RETRY] #814
Conversation
For some reason, the CI fails because of this false positive. The migrations mentioned on the logs have been removed. I wonder if this is an outdated cache issue.
|
mvj/settings.py
Outdated
MEDIA_URL = "/media/" | ||
STATIC_URL = "/static/" | ||
PRIVATE_FILES_BASE_URL = "/private_files/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No base url is needed
utils/models/fields.py
Outdated
super().__init__(**kwargs) | ||
self.storage = PrivateFileSystemStorage( | ||
location=settings.PRIVATE_FILES_LOCATION, | ||
base_url=settings.PRIVATE_FILES_BASE_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No base url needed
utils/models/fields.py
Outdated
from django.db import models | ||
|
||
|
||
class PrivateFileSystemStorage(FileSystemStorage): ... # noqa: E701 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider adding the location in the init of this class, since it is something we do not want to be configurable for this storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
All file fields are made into
PrivateFileFields
that have a custom file storage configured to them. The default for local settings is to save them to the codebase root under the/attachments/
directory, but theATTACHMENTS_LOCATION
andATTACHMENTS_BASE_URL
settings determine where the files will be stored.