python 2.7 - why '^(?[0-P<id>9]+)/$' is not a valid regular expression in django? -


i created new different url , view.after error showing.. newly created url , views following

url(r'^$', views.deletecontent, name="delete"), 

view :

def deletecontent(request, id):     if not request.user.is_authenticated():         return redirect('accounts:login')      todo = get_object_or_404(todo, id=id)     todo.delete()      return render(request,"index.html") 

your regex not invalid in django, invalid anywhere. think have mistyped it.

the regex ^(?[0-p<id>9]+)/$ totally invalid, drop in regex101.com, @jonrsharpe said, , see says:

  • (? incomplete group structure
  • ) incomplete group structure

you can have @ the docs:

url(r'^articles/(?p<year>[0-9]{4})/$', views.year_archive) 

this sample url regex year. see how formatted.

you should write regex in order make valid:

^(?p<id>[0-9]+)/$ 

it means id parameter, numeric ([0-9]+)

edit: or can use \d+ instead of [0-9]+, more straightforward , says "id digit".


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -