404 error on /admin/blog/post

I got virtually to the end and everything seemed to be working fine and now I am getting a 404 error (both locally and on Heroku) when I try to go to Posts from the admin. It was working earlier but now no.

Everything else seems to work fine and I checked my code against the Github repo but I can't see the problem.

Any hints on where I might look?

Sorry You must be a logged in, registered user to answer a question.

Answers

Hello Kenneth,

Here is the code for microblog/urls.py :

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib import admin
from . import views
admin.autodiscover()
urlpatterns = patterns('',
    url(r'^$', views.HomepageView.as_view(), name="home"),
    url(r'blog/', include("blog.urls", namespace="blog")),
    url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
    (r'^static/(.*)$', 'django.views.static.serve', {
        'document_root': settings.STATIC_ROOT
    }),
)

and the code for blog/urls.py

from django.conf.urls import patterns, url
from . import views
urlpatterns = patterns('',
    url(r'^$', views.PostListView.as_view(), name="list"),
    url(r'(?P<slug>[\w-]+)/$', views.PostDetailView.as_view(), name="detail"),
)
Great tutorials! I really like the new one on testing!
Norman Secord on
Yep, that's it. Thanks!! I stared at the code for hours and didn't see it.
Norman Secord on
Looks like you need a `^` before `blog` in the `microblogs.urls` file. That'll force the URL string to only match if it *starts* with "blog", not just if it contains "blog".
kennethlove (Staff) on

Update: when I click on Blog on the Admin page, I am taken to http://127.0.0.1:8888/admin/blog/ and this is displaying the blog_list page (i.e., identical to http://127.0.0.1:8888/blog/), not an admin page as I would expect.

I am using Django 1.5 but I wouldn't expect that to make a difference here. I've gone line by line and checked my code against the Github repo and see no differences. I'm stumped.

Sounds like an issue with URLs to me. Can you share your blog.urls and microblog.urls?
kennethlove (Staff) on