문제

I am trying to build a custom generated RSS feed using django's built in Syndication Framework. I am using mongoengine to interface django with mongoDB.

I am storing a set of documents that have a list of tags attached to each document. It is modeled as the following:

 class Request(Document):
     ...
     tags = ListField(StringField())
     ...

Ideally what I'd like to do is to have users type in a series of tags and get an rss feed for a list of recent documents with that tag. Ex. .../subscribe/One/Two would pull up a feed with tags of "One" and "Two".

I've mapped my urls.py file to match this:

url(r'^subscribe/(?P<pattern>.+)', KeywordsFeed(), name='subscribe')

But I keep getting an error saying that

settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Since I'm using mongoengine, my settings file looks like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.dummy', 
    }
}
MONGODB_NAME = 'mydb'
mongoengine.connect(MONGODB_NAME)

Here is 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

My thinking is that the syndication framework is doing some backend validation before serving the feed. I could also be understanding this framework wrong. Any advice would be much appreciated. Thanks!

도움이 되었습니까?

해결책

I think maybe it's lost more configure to connect DB.

Give IP, username and password for connection.

Example:

from mongoengine import register_connection

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.dummy',
    }
}

LOCAL_DBS = {
    'default':{
        'NAME': 'your_db_name',
        'HOST': '127.0.0.1',
        'PORT': '',
        'USER': 'user_name',
        'PASSWORD': 'password'
    },
}

MY_DB = LOCAL_DBS['default']
register_connection('default', MY_DB['NAME'], host=MY_DB['HOST'],
                    username=MY_DB['USER'], password=MY_DB['PASSWORD'])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top