Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==model.py==
- class ContentRating(EmbeddedDocument):
- content = ReferenceField(Content)
- rating = FloatField(default=5000)
- class Target(Document):
- age = IntField(min_value=20,max_value=60)
- gender = StringField(max_length=1,choices=['M','F'])
- location = GeoPointField()
- videos = ListField(EmbeddedDocumentField(ContentRating))
- ==django shell==
- >>>cr1=ContentRating()
- >>>cr1.content=Content.objects(title="Video3")
- >>>
- >>>for x in range(20,30):
- ... t=Target()
- ... t.age=x
- ... t.gender='M'
- ... t.location=[10,20]
- ... t.videos.append(cr1)
- ... t.save()
- Traceback (most recent call last):
- File "<console>", line 7, in <module>
- File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/document.py", line 73, in save
- self.validate()
- File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/base.py", line 357, in validate
- field._validate(value)
- File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/base.py", line 103, in _validate
- self.validate(value)
- File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/fields.py", line 346, in validate
- raise ValidationError('Invalid ListField item (%s)' % str(item))
- ValidationError: Invalid ListField item (ContentRating object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement