在Flask-Admin中将图像添加到MongoDB图像列表时出错

时间:2015-01-25 16:16:27

标签: python flask mongoengine flask-admin

我有这个型号:

class Merchandise(Document):
   image_gallery = ListField(ImageField(collection_name='image'))

当我在Flask-Admin中添加图像时,出现此错误:

Traceback (most recent call last):
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask_admin/base.py", line 68, in inner
    return self._run_view(f, *args, **kwargs)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask_admin/base.py", line 344, in _run_view
    return fn(self, *args, **kwargs)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask_admin/model/base.py", line 1374, in edit_view
    if self.update_model(form, model):
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask_admin/contrib/mongoengine/view.py", line 536, in update_model
    if not self.handle_view_exception(ex):
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/flask_admin/contrib/mongoengine/view.py", line 534, in update_model
    model.save()
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/mongoengine/document.py", line 224, in save
    self.validate(clean=clean)
  File "/home/lov3catch/lov3catch_venvs/profit_sellet/lib/python2.7/site-packages/mongoengine/base/document.py", line 323, in validate
    raise ValidationError(message, errors=errors)
ValidationError: ValidationError (Merchandise:54c0190f39731e3198f93c6d) ('NoneType' object has no attribute 'grid_id': ['image_gallery'])

我该如何解决这个问题?

0 个答案:

没有答案