0

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

admin/
^$ [name='home']
^adoptions/(\d+)/ [name='pet_detail']

The empty path didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

when I run server there was a warning

WARNINGS: ?: (2_0.W001) Your URL pattern '^$' [name='home'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path(). ?: (2_0.W001) Your URL pattern '^adoptions/(\d+)/' [name='pet_detail'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().

Here is the code..

from django.contrib import admin
from django.urls import path
from adoptions import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path(r'^$', views.home, name='home'),
    path(r'^adoptions/(\d+)/', views.pet_detail, name='pet_detail'),
]
Usman Gill
  • 31
  • 4
  • 12
  • Please don't just copy and paste an error message. Show the code that is causing the error. – Alasdair Mar 09 '18 at 11:39
  • 1
    This is a duplicate of https://stackoverflow.com/questions/47661536/. If you are using `path`, you should use `path('', ...)` instead of `path(r'^$', ...)`. – Alasdair Mar 09 '18 at 11:41

1 Answers1

0

As said in the comments by @Alasdair, the new path shoudn't have the r

urlpatterns = [
    path('admin/', admin.site.urls),
    path('^$', views.home, name='home'),
    path('^adoptions/(\d+)/', views.pet_detail, name='pet_detail'),
]
Walucas
  • 2,549
  • 1
  • 21
  • 44