我收到以下错误
NoReverseMatch at /blog/index/
和
Reverse for 'feed_articles' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
只是因为我删除/注释了一个我知道更需要的网址。网址也不是博客/索引。有些东西告诉我这是一个订购问题,因为我之前已经在我的django应用程序中发生了这个问题。但我很困惑。这是我评论的内容
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
url(r'^index/$', views.index, name='index'),
url(r'^video_submission/$', views.video_submission, name='submission'),
url(r'^contact/$', views.contact, name='contact'),
url(r'^privacy/$', views.privacy, name='privacy'),
url(r'^dmca/$', views.dmca, name='dmca'),
url(r'^terms/$', views.terms, name='terms'),
url(r'^search/$', views.post_search, name='post_search'),
url(r'^create/$', views.post_create, name='create'),
url(r'^images/$', views.static_images, name='static_images'),
url(r'^video_agreement/$', views.video_agreement, name='video_agreement'),
### url(r'^feed_articles/$', views.articles_list, name='feed_articles'),
url(r'^feeds/$', views.feed_list, name='feed_list'),
url(r'^feeds/new$', views.new_feed, name='new_feed'),
url(r'^(?P<id>\d+)/feed_delete/$', views.feed_delete, name='feed_delete'),
url(r'^(?P<id>\d+)/article_delete/$', views.article_delete, name='article_delete'),
url(r'^tag/(?P<tag_slug>[-\w]+)/$', views.post_list,
name='post_list_by_tag'),
url(r'^(?P<slug>[\w-]+)/$', views.post_detail, name='post_detail'),
url(r'^(?P<slug>[\w-]+)/edit/$', views.post_update, name='update'),
url(r'^(?P<id>\d+)/delete/$', views.post_delete, name='delete'),
如何更正语法以便解决此小问题?
编辑我的观点由博客/索引
调用{% extends 'blog/base.html' %}
{% load staticfiles %}
<style>
{% block style %}
#hite{
min-height: 720px;
}
.post{
min-height: 157px;
max-height: 157px;
width: 100%;
}
.tall{
height: 300px;
}
{% endblock style %}
</style>
{% block content %}
<div id="hite">
<h1>worldstar</h1>
{% for d in divs %}
<div class="col-sm-6 col-md-4" style="margin-top: 30px">
<div class="thumbnail thumb tall">
<img src="{{d.src}}" alt="{{ d.text }}" class="img-responsive post">
<div class="caption">
<h5>{{ d.text }}</h5>
<p></p>
<p><a href="{{d.url}}{{ d.href }}" class="btn btn-primary" role="button">World *</a></p>
</div>
</div>
</div>
{% endfor %}
{% for a in articles %}
<div class="col-sm-6 col-md-4" style="margin-top: 30px" >
<div class="thumbnail thumb tall">
<div class="caption">
<h4 style="height: 100px">{{a.title}}</h4>
<p>{{a.description|truncatechars:30 | safe}}</p>
<h4>From: {{a.feed|truncatechars:30}}</h4>
<p>
<a href="{{a.url}}" target="_blank" class="btn btn-primary">View Article</a>
{% if user.is_authenticated %}
<a href="{% url 'blog:article_delete' a.id %}" class="btn btn-primary">delete</a>
{% endif %}
</p>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
我的feed_articles
{% extends 'blog/base.html' %}
<style>
{% block style %}
/*ul{*/
/*list-style: none;*/
/*}*/
#hi{
min-height: 720px;
margin-top: 15px;
}
{% endblock style %}
</style>
{% block jumbotron %}
<h1>HArticles</h1>
<p> Have a look around at some of the latest news Here and abroad</p>
{% endblock jumbotron %}
{% block content %}
<div class="row" id="hi">
{% for a in articles %}
<div class="col-xs-12 col-sm-4 col-md-3 col-lg-6" >
<div class="thumbnail" style="height: 250px; padding-left: 10px">
<h4 style="height: 100px">{{a.title}}</h4>
<p>{{a.description|truncatechars:30 | safe}}</p>
<h4>From: {{a.feed|truncatechars:30}}</h4>
<p>
<a href="{{a.url}}" target="_blank" class="btn btn-primary">View Article</a>
{% if user.is_authenticated %}
<a href="{% url 'blog:article_delete' a.id %}" class="btn btn-primary">delete</a>
{% endif %}
</p>
</div>
</div>
{% endfor %}
</div>
{% endblock content %}
{% block aside %}
<h3 class="panel-body panel panel-default text-center"></h3>
{% endblock aside %}
答案 0 :(得分:0)
找到当&#39; / blog / index /&#39;时正在调用的任何视图呈现的模板。请求,并在{% url 'path_to_this_urls_file:feed_articles' %}
的模板中查找。还要查看该模板扩展和/或包含的任何模板,包括模板标签。