Advertisement
SparrowG

choices issue

Jun 9th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. == App model ==
  2. class Target(Document):
  3.     Age = IntField()
  4.     Gender = StringField(max_length=1,choices=(('M','Male'),('F','Female')))
  5.     Videos = SortedListField(EmbeddedDocumentField(ContentRating))
  6.    
  7.  
  8. ==Django shell ==
  9.  
  10. t=Target(Age=24,Gender='M')
  11. t.Videos.append(cr)
  12. t.save()
  13. Traceback (most recent call last):
  14.   File "<console>", line 1, in <module>
  15.   File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/document.py", line 73, in save
  16.     self.validate()
  17.   File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/base.py", line 357, in validate
  18.     field._validate(value)
  19.   File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/base.py", line 92, in _validate
  20.     % unicode(self.choices))
  21. ValidationError: Value must be one of (('M', 'Male'), ('F', 'Female')).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement