Flask-CouchDB : filtering per tag AND date
- From:
- Nicolas Steinmetz
- Date:
- 2011-06-27 @ 20:29
Hi,
I'm using Flask-CouchDB and I have an issue with displaying content per tag
and date.
Here is what I have :
class Bookmark(Document):
title = TextField()
description = TextField()
author = TextField(default=DISPLAY_NAME)
created_at = DateTimeField(default=datetime.datetime.now)
tag = ListField(TextField())
url = TextField()
hash = TextField()
doc_type = "Bookmark"
type = TextField(default="bookmark")
tagged = ViewField('bmarks', '''\
function (doc) {
if (doc.type == "bookmark" && doc.created_at && doc.tag != "") {
doc.tag.forEach(function (tag) {
emit([tag, doc.created_at], doc);
});
};
}''', descending=True)
[...]
@app.route('/tag/<tag_name>')
def show_marks_for_tag(tag_name):
page = paginate(Bookmark.tagged[tag_name], 10,
request.args.get('start'))
return render_template('tag.html', page=page, tag_name=tag_name)
If in my view, I only have :
emit(tag, doc);
It works but at a date point of view, it's a mess.
I would like to filter per tag and per date. Looks this one works in Futon
:
emit([tag, doc.created_at], doc);
Looks that page remains empty in this case.
So did I miss something or are there some bugs ?
Thanks,
Nicolas
--
Nicolas Steinmetz
http://www.steinmetz.fr - http://nicolas.steinmetz.fr/
Re: Flask-CouchDB : filtering per tag AND date
- From:
- Nicolas Steinmetz
- Date:
- 2011-07-05 @ 09:06
2011/6/27 Nicolas Steinmetz <nsteinmetz@gmail.com>
>
> So did I miss something or are there some bugs ?
>
>
Nobody for some clue or solution ?
Thanks,
Nicolas
--
Nicolas Steinmetz
http://www.steinmetz.fr - http://nicolas.steinmetz.fr/