Skip to main content

File Context provides an easy way to store different documents/attachments

Project description

Django File Context

.. image::
.. image::
.. image::

File Context provides an easy way to store different documents/attachments


The full documentation is at


Install Django File Context::

pip install django-file-context

Add it to your `INSTALLED_APPS`:

.. code-block:: python


You need to add this to your INSTALLED_APPS, because we have our own

Add Django File Context's URL patterns:

.. code-block:: python

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.


* Generic File model so you can store different kinds of files, images,
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.


1. First of all, define your first model

:: python
from file_context.managers import Files

class MyModel(models.Model):

name = models.CharField(max_length=128)

files = Files()

2. That's it.
3. You can use the Files API to attach files to MyModel instances, using:

:: python

uploaded_file = File.objects.get(pk=1)
a = MyModel.objects.create(name='foo')

Running Tests

Does the code actually work?


source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox


Tools used in rendering this package:

* Huge props to django-taggit that inspired me to do the descritor

* Cookiecutter_
* `cookiecutter-djangopackage`_

.. _Cookiecutter:
.. _`cookiecutter-djangopackage`:


0.1.0 (2017-10-25)

* First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-file-context-0.2.9.tar.gz (10.9 kB view hashes)

Uploaded source

Built Distribution

django_file_context-0.2.9-py2.py3-none-any.whl (13.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page