Error Django: Page not found (404)

0

I can not make my form url work in django. Error description:

  

Using the URLconf defined in django1_project.urls, Django tried these URL patterns, in this order:
  1. ^ admin /
  2. ^ pet ^ $ [name = 'index']
  3. ^ pet ^ new $ [name = 'petView']
  4. ^ pet ^ pet / new $ [name = 'petView']
  5. ^ adoption
  The current URL, pet / new, did not 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.

My URL.PY file inside the django project folder:

from django.conf.urls import url,include
from apps.mascota.views import index, mascotaView

urlpatterns = [
    url(r'^$', index,name='index'),
    url(r'^nuevo$',mascotaView,name='mascotaView'),
    url(r'^mascota/nuevo$',mascotaView,name='mascotaView'),
]

My URL.PY file inside the root folder of the django general project:

from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^mascota', include('apps.mascota.urls', namespace='mascota')),
    url(r'^adopcion', include('apps.adopcion.urls',namespace='adopcion')),
]

I can not find the error. What would be the reason why I did not find the url http: //127.0.0.1:8000/mascota/nuevo?

    
asked by Nahuel Jakobson 20.03.2017 в 15:54
source

1 answer

1

Your url file inside the root folder modify it to:

from django.conf.urls import url,include from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^mascota/', include('apps.mascota.urls', namespace='mascota')),
    url(r'^adopcion', include('apps.adopcion.urls',namespace='adopcion')), ]

Note the "/" at the end of the pet, this indicates that all the urls that you will include in your apps.mascota.urls files will be prefixed by the "/"

    
answered by 20.03.2017 / 16:37
source