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

Create custom model PathField for Library model for data_file_paths attribute #818

Open
avrohomgottlieb opened this issue Jul 29, 2024 · 0 comments

Comments

@avrohomgottlieb
Copy link
Contributor

Context

The data_file_paths attribute on the Library model is currently an ArrayField of TextFields, which saves an array of file paths from an external s3 bucket representing a library instance's data files currently hosted on s3. While the Django ORM does offer a mechanism to save local file paths to the db with FilePathField, it does not offer a way to save remote file paths, which is our use case.

Problem or idea

With this being said, Django does offer the ability to create custom model fields, which we would be able to utilize to suite our use case. For us it would be acceptable for the actual representation of the path to be as a TextField in the database, but we need our getters and setters to deal directly with Path objects. As such, leveraging a custom model field will allow us to wrap these getting and setting operations with the creation and destruction of Path objects as they are transformed to and from str / TextField objects.

Solution or next step

Below is the Django tutorial for creating a custom model field. Once this ticket is given the green light, I will develop a solution for it.

https://docs.djangoproject.com/en/5.0/howto/custom-model-fields/

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

1 participant