[Fixed]-Django Admin urls

45👍

In Django 1.9+, you don’t need to use include. Use the callable admin.site.urls, not the string 'admin.site.urls'.

url(r'^admin/', admin.site.urls),

In Django 2.0+, you can use path() instead of url().

path('admin/', admin.site.urls),

In Django < 1.9 you pass admin.site.urls to include.

url(r'^admin/', include(admin.site.urls)),

To reverse the admin index url, change the url tag in your template to:

{% url "admin:index" %}

Leave a comment