I am trying to catch all URLs from the safer app and send them to a catch all view; for example:
http://127.0.0.1:8000/saferdb/123
http://127.0.0.1:8000/saferdb/12
I think I have an issue with my reg ex in url.py:
from django.conf.urls import url
from . import views
app_name = 'saferdb'
urlpatterns = [
url(r'^/$', views.index, name='index'),
url(r'^(?P<pk>[0-9]+)/$', views.detail, name='detail'),
]
Views.py is the sample code from the django tutorial:
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from .models import Question
def index(request):
latest_question_list = Question.objects.all()[:5]
output = ', '.join([q.DOT_Number for q in latest_question_list])
return HttpResponse(output)
def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)
I noticed that /saferdb/ will not work unless the reg ex contains a slash: r'^/$' instead of r'^$' as shown in the django tutorial.
/at the end of the /saferdb in the main urls.py file.