开发者

How does get the title and content of this code?

I get this string:

{'id': 1, 'weight': 101, 'attrs': {'date_added': 1265274382, 'group_id': 1}}{'id': 2, 'weight': 100, 'attrs': {'date_added': 1265274382, 'group_id': 1}}{'id': 4, 'weight': 100, 'attrs': {'date_added': 1265274382, 'group_id': 2}}

I want to get the real data (title and content).

My view is:

from djangosphinx.models import SphinxSearch,SphinxQuerySet
def xx(request):
    queryset =Document.search.query(u'test')
    return HttpResponse(queryset)#
    #return render_to_resp开发者_JAVA百科onse('a.html',{'a':queryset})#

And my model is:

import datetime

class Group(models.Model):
    name = models.CharField(max_length=32)

class Document(models.Model):
    group       = models.ForeignKey(Group)
    date_added  = models.DateTimeField(default=datetime.datetime.now)
    title       = models.CharField(max_length=32)
    content     = models.TextField()

    search      = SphinxQuerySet(index="test1")

    class Meta:
        db_table = 'documents'

How can I change my code to show the title and content.


I think this link should be helpful for you http://pkarl.com/articles/guide-django-full-text-search-sphinx-and-django-sp/ According to the information provided:

You have to slice the results before you can use them

So you would have

list(queryset)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜