简体   繁体   English

如何在 Django 中创建正确的正则表达式?

[英]how can i make a correct regex in django?

I need to make regex to make a button witch put me on other website我需要制作正则表达式来制作一个按钮女巫把我放在其他网站上

this is my re_path:这是我的 re_path:

re_path (r'^detaletournament(?P<turnament_id>[0-9]+)/$',detaletournament)

Using the URLconf defined in projekt.urls, Django tried these URL patterns, in this order:使用 projekt.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:

admin/
tir
login
register
usertournaments
turnament
addturnament
takepart
deletetournament
quittournament
mytournaments
webturnament
profile
^detaletournament(?P<turnament_id>[0-9]+)/$

The current path, detaletournament, didn't match any of these.当前的路径 detaletournament 与这些都不匹配。

  1. You probably meant for the regex to be r'^detaletournament/(?P<turnament_id>[0-9]+)/$' (note the added / )您可能希望正则表达式为r'^detaletournament/(?P<turnament_id>[0-9]+)/$' (注意添加的 / )
  2. The URL you should try is then detaletournament/5/ for example, you just tried the regular expression itself as a URL and that doesn't work, because it expects a number.您应该尝试的 URL 是 detaletournament/5/ 例如,您只是尝试将正则表达式本身作为 URL 并且不起作用,因为它需要一个数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM