在Wagtail博客中找不到的标签:Django使用mysite.urls中定义的URLconf,尝试了这些URL模式

时间:2019-01-29 06:11:44

标签: wagtail

我正在关注Wagtail v2.4 tutorial,并为博客添加了标记功能。但是,当我单击博客文章上的标签链接时,出现404错误。标签索引页面(/tags/)显示所有没有标签的帖子。我只创建了一个带有标签的帖子。

  

找不到页面(404)

     

请求方法:GET

     

请求网址:http://localhost:8000/tags/tag%3Dnewswithimages

     

Django使用koamrn.urls中定义的URLconf,按以下顺序尝试了以下URL模式:

     
      
  1. ^ django-admin /
  2.   
  3. ^ admin /
  4.   
  5. ^ documents /
  6.   
  7. ^ search / $ [name ='search']
  8.   
  9. ^ _ util / authenticate_with_password /(\ d +)/(\ d +)/ $ [name ='wagtailcore_authenticate_with_password']
  10.   
  11. ^ _ util / login / $ [name ='wagtailcore_login']
  12.   
  13. ^((?:[\ w-] + /)*)$ [name ='wagtail_serve']
  14.   
  15. ^ static /(?P。*)$
  16.   
  17. ^ media /(?P。*)$
  18.   
     

当前路径tag / tag = newswithimages与任何这些都不匹配。

我猜我需要在urls.py中添加路径吗?

from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

from search import views as search_views

urlpatterns = [
    url(r'^django-admin/', admin.site.urls),

    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^documents/', include(wagtaildocs_urls)),

    url(r'^search/$', search_views.search, name='search'),

    # For anything not caught by a more specific rule above, hand over to
    # Wagtail's page serving mechanism. This should be the last pattern in
    # the list:
    url(r'', include(wagtail_urls)),

    # Alternatively, if you want Wagtail pages to be served from a subpath
    # of your site, rather than the site root:
    #    url(r'^pages/', include(wagtail_urls)),
]


if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

# Serve static and media files from development server
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

news_tag_index_page.html

{% extends "base.html" %}
{% load wagtailcore_tags %}

{% block content %}
    {% if request.GET.tag|length %}
        <h4>Showing pages tagged "{{ request.GET.tag }}"</h4>
    {% endif %}

    {% for newspage in newspages %}

        <p>
            <strong><a href="{% pageurl newspage %}">{{ newspage.title }}</a></strong><br />
            <small>Revised: {{ newspage.latest_revision_created_at }}</small><br />
            {% if newspage.author %}
                <p>By {{ newspage.author.profile }}</p>
            {% endif %}
        </p>

    {% empty %}
        No pages found with that tag.
    {% endfor %}
{% endblock %}

2 个答案:

答案 0 :(得分:3)

标签列表页面的URL应该是{ string gitCommand = "git bash"; string gitAddArgument = @"add -A" ; string gitCommitArgument = @"commit""explanations_of_changes"" "; string gitPushArgument = @"push our_remote"; Process.Start(gitCommand, gitAddArgument ); Process.Start(gitCommand, gitCommitArgument ); Process.Start(gitCommand, gitPushArgument ); } ,而不是set operation。您最有可能在list1=[1,2,3,4] list2=[1,5,3,4] print(set(list1) ^ set(list2)) 的链接中打了一个错字:

/tags?tag=newswithimages

答案 1 :(得分:1)

您只需要继续阅读本教程即可:)

“访问带有标签的博客帖子现在应该在底部显示一组链接的按钮-每个标签一个。但是,单击按钮将获得404,因为我们尚未定义“标签”视图。”

MFCreateDXSurfaceBuffer