Commit f220ea36 authored by liuzheng712's avatar liuzheng712

upload file with user id path

parent 7a25f348
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from django.db import models from django.db import models
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
import time
class UserGroup(models.Model): class UserGroup(models.Model):
name = models.CharField(max_length=80, unique=True) name = models.CharField(max_length=80, unique=True)
...@@ -127,6 +127,8 @@ class AdminGroup(models.Model): ...@@ -127,6 +127,8 @@ class AdminGroup(models.Model):
class Document(models.Model): class Document(models.Model):
# TODO: upload path with userID def upload_to(self, filename):
docfile = models.FileField(upload_to='upload/%Y/%m/%d') return 'upload/'+str(self.user.id)+time.strftime('/%Y/%m/%d/', time.localtime())+filename
docfile = models.FileField(upload_to=upload_to)
user = models.ForeignKey(User) user = models.ForeignKey(User)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment