8f811db7c8
* add new primary_key field. * Add new field, populate data, change to being pk, change name, double length of name field, and set it to unique * change version, and add new migration * bump down the size, 767/4 = 191 * update readme * remove models.py comment
24 lines
722 B
Python
24 lines
722 B
Python
from django.db import models
|
|
|
|
|
|
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 __unicode__(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)
|