使用django2.0.4的 path匹配那里会出错
两种解决途径:
1使用django2.0提供的path转换器,直接使用‘<>’捕获值,例如<int:article_id>,需指定类型
2from django.urls import re_path,然后讲该行开头的path改为re_path,其他不变
两种解决途径:
1使用django2.0提供的path转换器,直接使用‘<>’捕获值,例如<int:article_id>,需指定类型
2from django.urls import re_path,然后讲该行开头的path改为re_path,其他不变
2018-04-18
如果报错找不到模板,需要在setting.py的TEMPLATES中加上 'DIRS': [os.path.join(BASE_DIR, 'templates')]
2018-04-18
python3.6 Django2.0
from django.http import HttpResponseRedirect def edit_action(request):
...
articles = models.Article.objects.all()
#return render(request, 'index.html', {'articles': articles})
return HttpResponseRedirect('/blog/index') return HttpResponseRedirect('/blog/index')
from django.http import HttpResponseRedirect def edit_action(request):
...
articles = models.Article.objects.all()
#return render(request, 'index.html', {'articles': articles})
return HttpResponseRedirect('/blog/index') return HttpResponseRedirect('/blog/index')
2018-04-17
最新回答 / qq__18
File "D:\Varsha\python\myapp\app\views.py", line 7 article = models.Article.objects.get(pk=1) ^IndentationError: expected an indented block看错误提示,此处只需要缩进。检查下“article”这里格式对不对
2018-04-17
dictionary update sequence element #0 has length 7; 2 is required 报错
2018-04-16
django2.0,python 3.6
都不需要改,直接超链接就可以了
<a href="/blog/article/{{art.id}}">{{art.title}}</a>
都不需要改,直接超链接就可以了
<a href="/blog/article/{{art.id}}">{{art.title}}</a>
2018-04-15
python3.6 Django2.0
urlpatterns = [
path('index/', views.index),
path('article/<int:article_id>', views.article_page, ),
]
urlpatterns = [
path('index/', views.index),
path('article/<int:article_id>', views.article_page, ),
]
2018-04-15