Na urls.py tenho o seguinte código, conforme vídeo:
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
url(r'^$','perfis.views.index'),
url(r'^perfis/(?P<perfil_id>\d+)$','perfis.views.exibir')
)
E na views.py, o código abaixo:
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request,'index.html') # arquivo dentro de templates
def exibir(request,perfil_id):
print 'ID do perfil recebido: %s' % (perfil_id)
return render(request,'perfil.html')
Ao acessar http://localhost:8000/perfis/12/ recebo erro:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/perfis/12/
Using the URLconf defined in connectedin.urls, Django tried these URL patterns, in this order:
^admin/
^ ^$
^ ^perfis/(?P<perfil_id>\d+)$
The current URL, perfis/12/, 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.