在此之後正式tutorial我編寫這樣的:問題mongoengine:ReferenceFields將默認使用的ObjectId
#! /usr/bin/env python
from mongoengine import *
connect('tumbleblog')
class User(Document):
email = StringField(required=True)
first_name = StringField(max_length=50)
last_name = StringField(max_length=50)
class Comment(EmbeddedDocument):
content = StringField()
name = StringField(max_length=120)
class Post(Document):
title = StringField(max_length=120, required=True)
author = ReferenceField(User, reverse_delete_rule=CASCADE)
tags = ListField(StringField(max_length=30))
comments = ListField(EmbeddedDocumentField(Comment))
class TextPost(Post):
content = StringField()
class ImagePost(Post):
image_path = StringField()
class LinkPost(Post):
link_url = StringField()
john = User(email="[email protected]",first_name='john', last_name='doe')
john.save()
但我不知道爲什麼試圖運行它,它說的時候:
/Library/Python/2.7/site-packages/mongoengine/fields.py:736: FutureWarning: ReferenceFields will default to using ObjectId strings in 0.8, set DBRef=True if this isn't desired
warnings.warn(msg, FutureWarning)
/Library/Python/2.7/site-packages/mongoengine/base.py:589: FutureWarning: TextPost uses inheritance, the default for allow_inheritance is changing to off by default. Please add it to the document meta.
FutureWarning
/Library/Python/2.7/site-packages/mongoengine/base.py:589: FutureWarning: ImagePost uses inheritance, the default for allow_inheritance is changing to off by default. Please add it to the document meta.
FutureWarning
/Library/Python/2.7/site-packages/mongoengine/base.py:589: FutureWarning: LinkPost uses inheritance, the default for allow_inheritance is changing to off by default. Please add it to the document meta.
FutureWarning
[Finished in 0.2s]
我哪裏出錯了?我遵循官方教程..我錯過了什麼?
PS MongoDB是啓動和運行
沒有什麼真正的'錯誤'。未來的警告是Python和其他語言中的一個常見習慣用法,以提醒您將會棄用的內容。 – Petri