亲测django2.0.5版本要这么写:
from django.contrib import admin
from django.urls import path
from blog import views
urlpatterns = [
path('admin/', admin.site.urls),
path('hello',views.hello),
]
from django.contrib import admin
from django.urls import path
from blog import views
urlpatterns = [
path('admin/', admin.site.urls),
path('hello',views.hello),
]
2018-05-05
url配置 建立url与响应函数之间的关系 mysite/urls.py -->urlpatterns
视图views blog/views.py
模型models blog/models.py
模板templates blog/templates/*
流程:1.拿到模板
2. 查询数据
3.数据传递给context对象
4.数据渲染模板
5.返回用户模板
视图views blog/views.py
模型models blog/models.py
模板templates blog/templates/*
流程:1.拿到模板
2. 查询数据
3.数据传递给context对象
4.数据渲染模板
5.返回用户模板
2018-04-30
最新回答 / kaibisikai
from django.contrib import admin from django.urls import path from django.conf.urls import url from blog import views urlpatterns = [ path('admin/', admin.site.urls), url(r'helloworld', views.hello) ] 写成这样
2018-04-26
TypeError: view must be a callable or a list/tuple in the case of include() 的解决方法:
在django2.0.3中,需要按照如下方法解决:
from django.contrib import admin
from django.urls import path
from blog.views import hello
urlpatterns = [
path('admin/', admin.site.urls),
path(r'hello/', hello, name='hello')
]
在django2.0.3中,需要按照如下方法解决:
from django.contrib import admin
from django.urls import path
from blog.views import hello
urlpatterns = [
path('admin/', admin.site.urls),
path(r'hello/', hello, name='hello')
]
2018-03-23