1

urls.py現在、バグのパーマリンクを1 つ取得するエントリがあります。

from django.conf.urls.defaults import *

from tagging.views import tagged_object_list

from bugs.models import Bug

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^workarounds/', include('workarounds.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    (r'^$', 'django.views.generic.simple.direct_to_template', {'template':'homepage.html'}),

    (r'^bugs/(?P<slug>[-\w]+)/$', 'bugs.views.bug_detail'),
    (r'^bugs/tagged/(?P<tag>[^/]+)/$', 
    'tagging.views.tagged_object_list',
    {
        'queryset_or_model': Bug,
        'template_name' : 'tag/lone.html'}),
    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

たとえば、URL を指定すると、bugs/tagged/firefoxFirefox のタグが表示されます。複数のタグで除外するにはどうすればよいですか? 例:および でfirefox+cssタグ付けされたすべてのオブジェクトを返します。firefoxcss

4

1 に答える 1

3

を使用する代わりに、独自のビューを作成する必要がありますtagging.views.tagged_object_list

(r'^bugs/tagged/(?P<tags>[-\w+]+)/$', your_tag_view)

ビューで、検索しているタグのリストを取得します。

tags = tags.split('+')

次に、TaggedItem.objects.get_by_modelタグのリストを便利に受け入れるクエリを使用します。

from tagging.models import TaggedItem
bugs = TaggedItem.objects.get_by_model(Bug, tags)
于 2010-06-21T14:16:55.597 に答える