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

Replace field with model #6

Open
hugorodgerbrown opened this issue Jul 26, 2017 · 0 comments
Open

Replace field with model #6

hugorodgerbrown opened this issue Jul 26, 2017 · 0 comments

Comments

@hugorodgerbrown
Copy link
Collaborator

Having the S3Upload field allows any text field on a model to become S3 compatible, however at large scale it can get out of hand - S3 interactions are spread across all models in the project. An alternative approach (which I've worked with in the past, with millions of files) is to have a single file-tracking model, and a OneToOne relationship on the model where required.

class TestModel(models.Model):

    # store the upload path on the model
    file1 = S3UploadField(dest='foo')

    # store the upload as separate object
    file2 = models.OneToOneField(S3Upload)

The advantage of this is that all uploads are held in a single table, and you can add useful metadata to each - the model field it is stored against, timestamps etc. The additional advantage is that you can then key audit events off this object - uploads, downloads etc. (See #5)

The disadvantage is that the initial implementation is harder - hooking the widget up so that you are creating the object and then the relationship to the parent, etc.

Both approaches could be combined - use the model if you want auditing, use the field if you don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant