File Context provides an easy way to store different documents/attachments
pip install django-file-context==0.2.9
File Context provides an easy way to store different documents/attachments
The full documentation is at https://django-file-context.readthedocs.io.
Install Django File Context:
pip install django-file-context
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'file_context.apps.FileContextConfig',
...
)
You need to add this to your INSTALLED_APPS, because we have our own models.
Add Django File Context's URL patterns:
from file_context import urls as file_context_urls
urlpatterns = [
...
url(r'^', include(file_context_urls)),
...
]
This is optional. Actually, you can include your own URLs.
etc, using a single model; * Attach/Detach the file model to other models * Cool descriptor, so you don't have to keep mangling GenericForeignKeys inside your models.
from file_context.managers import Files
class MyModel(models.Model):
name = models.CharField(max_length=128)
files = Files()
:: python
uploaded_file = File.objects.get(pk=1) a = MyModel.objects.create(name='foo') a.files.attach(uploaded_file) a.files.detach(uploaded_file) a.files.clear()
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Tools used in rendering this package:
idea!