简体   繁体   中英

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 (r'^detaletournament(?P<turnament_id>[0-9]+)/$',detaletournament)

Using the URLconf defined in projekt.urls, Django tried these URL patterns, in this order:

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.

  1. You probably meant for the regex to be r'^detaletournament/(?P<turnament_id>[0-9]+)/$' (note the added / )
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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