我被迫使用django 1.4来使用neo4j,我收到一条奇怪的消息,“accounts”不是注册的命名空间。肯定是,就在根源:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('accounts.urls', namespace='accounts')),
]
在settings.py中:
INSTALLED_APPS = (
...
'accounts',
)
TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), )
项目根目录中的我有模板/ accounts / index.html,它看起来正确,因为template_dirs指向该文件夹。它特别抱怨:
return render(request, 'accounts/index.html', locals())
没有返回一个namspace,它返回一个模板名称,从templates文件夹开始。如果它是相关的,在帐户应用程序(已安装)中,我有:
urls.py -
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('accounts.views',
url(r'^$', 'index', name='index'),
url(r'^register/$', 'register', name='register'),
url(r'^login/$', 'user_login_page', name='login'),
url(r'^logout/$', 'user_logout', name='logout'),
)
为什么具有导致NoReverseMatch的命名空间的东西不是已注册的命名空间?
答案 0 :(得分:2)
将其添加到基础html的顶部。
{% load url from future %}
答案 1 :(得分:0)
在1.4中,似乎是其他旧版本,final int EXAMS = 5;
Integer[] scores = new Integer [EXAMS]; // the only required change
for (int index = 0; index < EXAMS; index++) {
System.out.println("Enter the score for " + (index+1) +":");
scores[index] = kb.nextInt();
if (scores[index] < 0){
System.out.println("The number you have entered is invalid.");
scores[index] = kb.nextInt();
}
}
Arrays.sort(scores, Collections.reverseOrder());
System.out.println("The sorted int array is:");
for (int number : scores) {
System.out.println("Number = "+ number);
}
不被允许...只需要{% url 'accounts:register' %}