我无法从目录中映射html文件,但我已按照所有说明进行操作。
以下是我的项目urls.py: -
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
url(r'^articles/', include('article.urls')),
)
应用程序中的Views.py: -
from django.shortcuts import render_to_response
from article.models import Article
def articles(request):
return render_to_response('articles.html',{'articles':
Article.objects.all()})
def article(request, article_id=1):
return render_to_response('article.html',{'article':
Article.objects.get(id=article_id)})
app中的Urls.py:
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^all/$', 'artilce.views.articles'),
url(r'^get/(?P<article_id>\d+)/$', 'article.view.article'),
)
Settings.py将模板文件夹的确切位置显示为: -
TEMPLATE_DIRS = (
'C:\Python27\Scripts\django_test\article\templates',
请告知。它显示404页面上的文章,但无法映射。
答案 0 :(得分:1)
您需要为路径使用unix样式的正斜杠,即使在Windows上也是如此。请参阅此处的文档页面:https://docs.djangoproject.com/en/1.6/ref/settings/#template-dirs