1

I made a change in my models.py. I change the field from FileField() to ImageWithThumbsField()

from mongoengine import *
from gradfounder.settings import DBNAME
from embed_video.fields import EmbedVideoField
from thumbs import ImageWithThumbsField

##########################################
# Mongoengine registration/authentication
#from mongoengine.django.auth import User
##########################################

#connect(DBNAME)
# connect(DBNAME, host='127.0.0.1', port=27017)
connect(DBNAME, host='xxx.xxx.xxx.xxx', port=27017)

class Author(Document):
    # photo = FileField()
    photo = ImageWithThumbsField(upload_to="avatars")
    photoname = StringField()

Then I got this error

  File "C:\Python27\lib\site-packages\mongoengine\base\document.py", line 80, in
 __init__
    raise FieldDoesNotExist(msg)
FieldDoesNotExist: The field 'photo' does not exist on the document 'Author'

I tried to migrate and syncdb but got an error DatabaseError: (1050, "Table 'profiles_profile' already exists")

Anyone who wants to work on this together are welcome.

Aminah Nuraini
  • 18,120
  • 8
  • 90
  • 108

1 Answers1

5

Yes! I found the solution!

The error was caused by Mongoengine validation who got confused by the changed field. The solution is to disable the validation by adding this code:

class Author(Document):
    # photo = FileField()
    photo = ImageWithThumbsField(upload_to="avatars")
    photoname = StringField()
    meta = {'strict': False}

Thanks to this question! mongoengine - Ignore extra fields for schema validation

Community
  • 1
  • 1
Aminah Nuraini
  • 18,120
  • 8
  • 90
  • 108