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

Add support for using custom StoredUpload models #63

Open
jcohen02 opened this issue Sep 29, 2021 · 3 comments
Open

Add support for using custom StoredUpload models #63

jcohen02 opened this issue Sep 29, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request v0.7.0
Milestone

Comments

@jcohen02
Copy link
Collaborator

jcohen02 commented Sep 29, 2021

Based on the discussion in issue #62, it looks like there would be a benefit in supporting custom StoredUpload models. This adds to an earlier request for this functionality raised in #45.

This would address the issue where there is a need to link mulitple stored uploads to some other model instance.

At present this could be done by modifying StoredUpload to add a ForeignKey to the required application model. This implements a one-to-many relationship using Django's reverse implementation approach where it is implemented as a many-to-one relationship adding the ForeignKey on the object that represents the "many" side of the relationship. Modifying StoredUpload is not an ideal or recommended solution since it makes maintenance more complicated and also creates a strong link to django-drf-filepond meaning that the library can't be easily upgraded to a new version without making custom modifications.

Creating an intermediate model that contains multiple instances linking a single application model instance to each required django-drf-filepond StoredUpload instance is an alternative option. This is effectively the same as using a ManyToManyField on the application model to link to multiple StoredUpload instances, although I suppose this would be considered bad practice since it is actually modelling a one-to-many relationship but using a many-to-many as a workaround to avoid having to modify StoredUpload.

To resolve these challenges, a better option would be to support the use of a custom StoredUpload model that extends django-drf-filepond's StoredUpload. A setting DJANGO_DRF_FILEPOND_STORED_UPLOAD_MODEL or similar would then allow the custom model to be permanently selected, or a custom_model attribute on the store_upload API call would allow specifying the model on a case-by-case basis. stored_upload would then accept a dictionary of additional keyword arguments representing additional data to store in the custom model instance.

@jcohen02 jcohen02 added the enhancement New feature or request label Sep 29, 2021
@jcohen02 jcohen02 added this to the v0.5.0 milestone Sep 29, 2021
@jcohen02 jcohen02 self-assigned this Sep 29, 2021
@derek-adair
Copy link

derek-adair commented Apr 3, 2022

This seems nice. I am currently envoking store_upload, then get_stored_upload_file_data, then saving the image path to my model....

cringe

@derek-adair
Copy link

Django Allauth has this done quite eloquently if it helps to have an example.

@jcohen02 jcohen02 modified the milestones: v0.5.0, v0.6.0 Dec 5, 2022
@jcohen02
Copy link
Collaborator Author

I think this is going to have to be pushed back to v0.7.0 (or a 0.6 patch release) - I'm currently trying to get a 0.6 release out and unfortunatley won't have the time to work on this right away. Apologies for the long delay.

@jcohen02 jcohen02 modified the milestones: v0.6.0, v0.7.0 Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v0.7.0
Projects
None yet
Development

No branches or pull requests

2 participants