Django:使用upload_to功能

时间:2016-06-11 23:23:32

标签: python django mongodb django-models imagefield

我想在我的Django upload_to

中应用models.py
from mongoengine import *
from <project_name>.settings import DBNAME
from embed_video.fields import EmbedVideoField

class Author(Document):
    fk_user = IntField() #points to user id in sqlite3.
    first_name = StringField()
    last_name = StringField()
    # photo = FileField()
    photo = ImageField(upload_to="avatars")
    photoname = StringField()
    status = StringField()
    summary = StringField()
    name = StringField()

我遇到了这个令人困惑的错误:

    photo = ImageField(upload_to="avatars")
  File "C:\Python27\lib\site-packages\mongoengine\fields.py", line 1642, in __init__
    **kwargs)
  File "C:\Python27\lib\site-packages\mongoengine\fields.py", line 1397, in __init__
    super(FileField, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'upload_to'

有谁知道如何解决它?

我正在使用Django 1.5.11

更新

这些是我使用的所有模块和版本

  • 的Django == 1.5.11
  • Django的括号== 1.8.1
  • Django的调试工具栏== 1.3
  • Django的嵌入视频== 1.0.0
  • Django的无端分页== 2.0
  • 的django-mongodb的发动机== 0.6.0
  • Django的存储器== 1.1.8
  • djangotoolbox == 1.8.0
  • ECDSA == 0.13
  • httplib2的== 0.9.1
  • 蒙戈== 0.2.0
  • mongoengine == 0.10.0
  • 的MySQL-蟒== 1.2.5
  • 的paramiko == 1.15.2
  • 枕== 3.2.0
  • pycrypto == 2.6.1
  • pymongo == 3.0.3
  • 请求== 2.7.0
  • 南== 1.0.2
  • 轮== 0.24.0

0 个答案:

没有答案