django - 为什么我的 store.html 无法识别?
问题描述
我正在学习 Django Udemy 课程(James Carrigan),我只更新到 2.0.5
tree bookstore
bookstore
├── bookstore
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── settings.cpython-36.pyc
│ │ ├── urls.cpython-36.pyc
│ │ └── wsgi.cpython-36.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── manage.py
└── store
├── admin.py
├── apps.py
├── __init__.py
├── migrations
│ ├── __init__.py
│ └── __pycache__
│ └── __init__.cpython-36.pyc
├── models.py
├── __pycache__
│ ├── admin.cpython-36.pyc
│ ├── __init__.cpython-36.pyc
│ ├── models.cpython-36.pyc
│ └── views.cpython-36.pyc
├── templates
│ ├── store.html
│ └── template.html
├── tests.py
└── views.py
这些是我的看法
def index(request):
return render(request,'template.html')
def store(request):
return render(request,'store.html')
网址
from django.contrib import admin
from django.urls import path
from django.conf.urls import url
from store import views
urlpatterns = [
url(r'^', views.index ,name='index' ),
url(r'^store', views.store ,name='store' ),
path('admin/', admin.site.urls),
]
我在 HTML 样板文件中更改了行
<p>Welcome to mystery books and store template is changed!</p>
它没有看到 http://127.0.0.1:8000/store和 http://127.0.0.1:8000/index之间有任何区别
为什么我的其他 html 无法识别?
解决方案
您不会结束您的正则表达式模式,因此第一个匹配所有内容。
确保你结束你的正则表达式$
url(r'^$', views.index ,name='index' ),
url(r'^store$', views.store ,name='store' ),
推荐阅读
- excel - 交易数据多条件数组函数
- primefaces - 没有 p:calendar 的屏蔽日期时间输入
- r - 数据框列标题中的符号消失
- windows - 在 oci.core.model 的 LaunchInstanceDetails 方法的元数据参数中使用多个自定义脚本
- node.js - Loopback 需要 Node Cluster 模块,与Passenger不兼容
- laravel - Laravel 获取 id 与 whereHas 关系
- kubernetes - IBM Blockchain Platform 如何初始化链码?超级账本结构
- javascript - 如何使用 webpack 将 http 请求转发到 https?
- r - 将 NA 值与 heatmap.2 和(指定的)中断一起使用
- excel - 修复将空单元格转换为日期的 VBA 代码