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

StoredUpload should be hotswappable #45

Closed
brianedelman opened this issue Sep 9, 2020 · 3 comments
Closed

StoredUpload should be hotswappable #45

brianedelman opened this issue Sep 9, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@brianedelman
Copy link

Currently working on a project where I want StoredUpload to have some extra data attached to it and there currently isn't a way to define my own model for the library to use. Is that something on the roadmap/useful for others?

@jcohen02
Copy link
Collaborator

Thanks for raising this @brianedelman, this would certainly be a useful enhancement. Can you provide a little more detail as to what you had in mind in terms of the functionality you'd be looking for?

If you were to extend the StoredUpload model class with your custom model parameters and then have a new option in the settings where you could set the name of the stored upload class, say, DJANGO_DRF_FILEPOND_STORED_UPLOAD_CLASS, would this solve the issue? The store_upload function in api.py could then perhaps be extended to include an optional additional_params parameter where you'd pass in a dict containing the additional data to store in your custom StoredUpload object.

Alternatively, would you be looking for something more flexible where you can specify the upload model when you save the upload? I guess this could be handled by specifying the upload model name as a parameter to store_upload but then lookups would become very challenging so this probably needs more thought.

Yet another option would be that you create a separate model for your additional data that extends some placeholder model class. We then have an optional foreign key in the StoredUpload model where we can attach a reference to an additional model data class. You could then pass in a pre-created object to store_upload that contains your additional data and have this linked to the StoredUpload object that is saved.

Just a few thoughts on how this might be addressed. Let me know if you have any thoughts on what might work best for your use case or if you had something different in mind. Also happy to receive suggestions on what approach might be best from the general architecture perspective of the library.

I can look at implementing this, otherwise if you want to have a go and open a PR, that's also fine.

@jcohen02 jcohen02 added the enhancement New feature or request label Sep 11, 2020
@jcohen02 jcohen02 added this to the v0.4.0 milestone Sep 11, 2020
@jcohen02 jcohen02 linked a pull request Sep 11, 2020 that will close this issue
@jcohen02 jcohen02 modified the milestones: v0.4.0, v0.5.0 Sep 29, 2021
@jcohen02
Copy link
Collaborator

This issue has come up again in #62 and I've opened a new issue (#63) to work on this. Thanks @brianedelman for raising this initially and for your work looking at implementing this. I think I can see a simplified approach to addressing this initially (although I may well be missing something!) so will have a go.

I'm going to close this issue and move discussion to on this feature to #63. Do feel free to contribute or provide feedback on any implementation if you're still working with this and would find the feature helpful.

@jcohen02
Copy link
Collaborator

Discussion on this feature is continuing in #63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants