django-dbfilestorage/dbfilestorage/models.py
Tyrel Souza 4b7738c0f2
Python3 and Django 1.11 upgrade (#40)
* starting py3 upgrade

* b64 not base64

* more progress, some more future things, and encoding

* tox

* update circle.yml

* that version doesnt exist yet, oops

* install?

* sigh

* Docker me?

* update readme, requirements

* fix for python3

* python35

* morgan remediations

* does this work?

* how about this?

* one more time

* no blank lines?

* revert a bit

* add future imports
2018-03-01 15:32:02 -05:00

28 lines
874 B
Python

from __future__ import absolute_import, print_function, unicode_literals
from django.db import models
from future.utils import python_2_unicode_compatible
@python_2_unicode_compatible
class DBFile(models.Model):
""" Model to store and access uploaded files """
name = models.CharField(max_length=190, unique=True)
# file data
content_type = models.CharField(max_length=100)
b64 = models.TextField()
mtime = models.DateTimeField(auto_now=True)
def __str__(self):
return u"{name} <{content_type}>".format(
name=self.name, content_type=self.content_type)
def save(self, **kwargs):
if self.content_type is None:
# If content type guessing fails,
# use octet stream as a major fallback
self.content_type = "application/octet-stream"
super(DBFile, self).save(**kwargs)