Django urls.py gives a 404 error while trying to access a URL
I'm trying to create a Django app that uses these two urls, browse and
account but I am getting an error when I try to access either of these
two.
Using the URLconf defined in mediasite.urls, Django tried these URL
patterns, in this order:
^browse/
^admin/
The current URL, browse, didn't match any of these.
After looking over my code, I'm not sure where the error lies. The strange
thing is the admin site still works.
urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^browse/', include('media.urls')),
url(r'^admin/', include(admin.site.urls)),
)
media/urls.py:
from django.conf.urls.defaults import patterns, include, url
from django.views.generic import ListView, DetailView
from media.models import Video
urlpatterns = patterns('',
url(r'^videos', ListView.as_view(
queryset=Video.objects.all().order_by("-created")[:2],
template_name="media.html")),
url(r'^videos/(?P<pk>\d+)$', DetailView.as_view(
model=Video,
template_name="video.html")),
)
settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'media',
)
No comments:
Post a Comment