python - Django url参数错误
问题描述
这是我的问题:
Using the URLconf defined in Rase.urls, Django tried these URL patterns, in this order:
admin/
[name='index']
bio/<slug:username>/$ [name='bio']
The current path, bio/bussiere/, didn't match any of these.
网址是:
http://localhost:8000/bio/bussiere/
这是我的网址文件:
from django.urls import include, path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path("bio/<slug:username>/$", views.bio, name='bio'),
]
如果你有任何想法?
谢谢并恭祝安康
解决方案
您正在使用Django 2.0.X,其中 url 发生了很大变化。path()
只需删除尾随$时,您不需要对 url 使用正则表达式。所以网址应该是 -
path("bio/<slug:username>/", views.bio, name='bio')
推荐阅读
- docker - 如何设置在多个 Raspberry Pi 上运行的 dockerized Web 服务器?
- java - Jnlp 运行依赖库的函数
- integer - 线性规划问题:最小化使用的卡车数量
- python-3.x - Python3:分数
- java - 从表单后端获取数据
- swift - Xcode:在 UISlider 中没有更多上下文错误的表达式类型不明确
- javascript - 在 chrome.storage 中保存图像
- node.js - 在 foreach() 中使用 findOne
- android - 从本地 JSON 文件到列表的映射功能不起作用(颤动)
- python - 如何根据协程对序列进行排序?