1
我正嘗試使用內置於整合框架中的django構建一個自定義生成的RSS訂閱源。我正在使用mongoengine將django與mongoDB連接起來。與mongoengine一起使用django整合模塊
我正在存儲一組文檔,這些文檔具有附加到每個文檔的標籤列表。它做成如下:
class Request(Document):
...
tags = ListField(StringField())
...
理想是我想要做的就是讓用戶在一系列的標籤類型和獲得最近的文檔包含該標籤的列表的RSS feed。防爆。 .../subscribe/One/Two
會拉起「One」和「Two」標籤。
我映射我的urls.py文件以符合本:
url(r'^subscribe/(?P<pattern>.+)', KeywordsFeed(), name='subscribe')
但我不斷收到一個錯誤,指出
settings.DATABASES配置不當。請提供ENGINE值。檢查設置文檔以獲取更多細節。
由於我使用mongoengine,我的設置文件看起來像這樣:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy',
}
}
MONGODB_NAME = 'mydb'
mongoengine.connect(MONGODB_NAME)
這裏是feeds.py:
class KeywordsFeed(Feed):
title = "Data Request Repository"
link = "/"
description = "Description"
def get_object(self, request, pattern):
patternlist = string.split(pattern, r'/')
pdb.set_trace()
resultList = Request.objects(tags__in=patternlist)
if len(resultList<1):
raise ObjectDoesNotExist
return
def title(self, obj):
return obj.title
def description(self,obj):
return obj.description
def items(self, obj):
return obj
我的想法是,聚合框架做一些在提供Feed之前進行後端驗證。我也可以理解這個框架是錯誤的。任何意見將不勝感激。謝謝!
你想連接到[DB實(http://mongoengine-odm.readthedocs.org/guide/connecting.html#connecting-to-mongodb)? –
@PuffinGDI mongoDB在默認端口上的本地主機上運行。我可以使用視圖或shell對其進行各種查詢。 –
試試我的答案。我希望它可以幫助你:)。 –