Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Created June 20, 2018 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morenoh149/39be1ace1f99b9571fd2b6b96098075d to your computer and use it in GitHub Desktop.
Save morenoh149/39be1ace1f99b9571fd2b6b96098075d to your computer and use it in GitHub Desktop.
django admin unreachable
GET http://localhost:8000/admin
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/admin
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^ ^$ [name='index']
^admin/
^static\/(?P<path>.*)$
The current path, admin, didn't match any of these.
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
url(r'^', include('polls.urls')),
url(r'^admin/', admin.site.urls)
]
# Only serve static files from Django during development
# Use Google Cloud Storage or an alternative CDN for production
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
@morenoh149
Copy link
Author

django 2.0 uses path, do

from django.conf import settings
from django.contrib import admin
from django.urls import include, path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('polls.urls')),
]

# Only serve static files from Django during development
# Use Google Cloud Storage or an alternative CDN for production
if settings.DEBUG:
    urlpatterns += staticfiles_urlpatterns()

and open http://localhost:8000/admin

you should also update polls/urls.py but I'll leave that as an exercise for the reader, read the new syntax in django 2.0 at https://docs.djangoproject.com/en/2.0/intro/tutorial01/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment