tags_list tags split получаем все сообщения со всеми из тегов queryset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
tags_list = tags.split("+")
#получаем все сообщения со всеми из тегов
queryset=Entry.objects
for tag in tags_list: queryset = queryset.filter(tags__name=tag)
class Entry(models.Model):
title = models.CharField(max_length=200)
body = models.TextField(help_text="You can use row HTML.")
slug = SlugField(max_length=200)
pub_date = models.DateTimeField()
author = models.ForeignKey(User, null=True, blank=True)
upd_date = models.DateTimeField(auto_now=True)
is_draft = models.BooleanField(null=False, default=True)
category = models.ManyToManyField('Category', null=True, blank=True)
sites = models.ManyToManyField(Site)
comments_on = models.BooleanField(null=False, default=True)
objects = models.Manager()
on_site = CurrentSiteManager('sites')
tags = models.CharField(max_length=200)
class TaggedItem(models.Model):
tag = models.ForeignKey(Tag)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
class Tag(models.Model):
name = models.CharField(max_length=50, unique=True)
created = models.DateTimeField(editable=False, auto_now=True)
created_by = models.ForeignKey(User, null=True, blank=True)
#site = models.ManyToManyField(Site)