Skip to content

Commit

Permalink
Updated README.rst with usage example and additional notes
Browse files Browse the repository at this point in the history
  • Loading branch information
derekkwok committed Feb 25, 2016
1 parent ba2562d commit 17b2375
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
include README.rst
28 changes: 27 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ Warning: In many cases, storing files in the database is a BAD idea. Your databa

.. _StackExchange post: http://programmers.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database

This is a custom storage backend for storing files in the database instead of the file system. It is a drop-in replacement for Django's FileSystemStorage.
This is a custom storage backend for storing files in the database instead of the file system and is a drop-in replacement for Django's FileSystemStorage. Some benefits of this application:

* no changes needed to existing models, it just works (and if it doesn't, open a ticket!)
* django-admin is implemented and can be used to search, upload, download and manage files
* 100% code coverage with unit tests

Requirements
------------
Expand Down Expand Up @@ -58,3 +62,25 @@ Run database migrations
::

$ python manage.py migrate


How to Use
----------

No modification are needed for models to work properly.

.. code-block:: python
def user_directory_path(instance, filename):
return 'user_{0}/{1}'.format(instance.user.id, filename)
class MyModel(models.Model):
file_field1 = models.FileField()
file_field2 = models.FileField(upload_to='uploads/%Y/%m/%d/')
file_field3 = models.FileField(upload_to=user_directory_path)
Bugs?
-----

Create an issue at https://github.com/derekkwok/django-db-storage/issues
3 changes: 2 additions & 1 deletion dbstorage/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-22 21:47
# Generated by Django 1.9.2 on 2016-02-24 23:31
from __future__ import unicode_literals

from django.db import migrations, models
Expand All @@ -24,6 +24,7 @@ class Migration(migrations.Migration):
('updated_on', models.DateTimeField(auto_now=True)),
],
options={
'verbose_name': 'DB file',
'db_table': 'db_file',
},
),
Expand Down

0 comments on commit 17b2375

Please sign in to comment.