Home > Enterprise >  What the meaning of ^ for url
What the meaning of ^ for url

Time:01-26

It might be too simple question.

I have this urlpatterns in urls.py

urlpatterns = [
    url(r'^s3direct/', include('s3direct.urls')),
    path('admin/', admin.site.urls),
]

localhost/admin works, but localhost/s3direct shows the 404 error.

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8099/s3direct
Using the URLconf defined in djang_test.urls, Django tried these URL patterns, in this order:

^s3direct/
admin/
The current path, s3direct, didn’t match any of these.

(I use runserver at port 8099)

CodePudding user response:

The ^ in this case is a Regex-specific operator, meaning that it only matches the beginning of the string.

I believe that your problem is that you actually need to request http://localhost:8099/s3direct/ -- You're missing the trailing backslash

  •  Tags:  
  • Related