如何获取这段代码的标题和内容?
我得到这个字符串:
{'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}}
我想获取真实的数据(标题和内容)。
我的观点是:
from djangosphinx.models import SphinxSearch,SphinxQuerySet
def xx(request):
queryset =Document.search.query(u'test')
return HttpResponse(queryset)#
#return render_to_response('a.html',{'a':queryset})#
我的模型是:
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'
如何更改我的代码以显示标题和内容。
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_response('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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个链接应该对您有帮助 http ://pkarl.com/articles/guide-django-full-text-search-sphinx-and-django-sp/
根据提供的信息:
所以你会
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:
So you would have