Template Does Not Exist at /admin/login/

I am working my way through Christopher Trudeau’s book “Django In Action” to learn the language and have reached Chapter 5 on the Admin functions. I have created a superuser account, but then my browser says the templates/admin/login.html file does not exist.

The support links in urls and settings are what I read they are supposed to be, and I am not trying to customize anything but am keeping things as plain vanilla as possible.

I’d like to find the missing file and know where to install it. The Django documentation, if it can supply that file, is still very confusing to a noobe to Django like myself.

add your code for help.

How much code do you need to see? A zip of the entire RiffMates folder?
I admit I am new at this.

Welcome @Derrek2 !

It’s not something to be installed. Depending upon a number of different factors, it’s either something that is installed by default, or a file you need to create.

I think we can start with some background information. (I am not personally familiar with that book, so I don’t know what it’s trying to show you.)

What versions of Python and Django are you using? (Does it match the version being used in the book?)

Please describe the directory structure of your project (directories only, I don’t think we need to see all the files yet.)

However, please post your urls.py file and the INSTALLED_APPS section of your settings.py file.

Also, if there were any other changes to the settings.py file that the book had you make, please identify them here.

Side note: When posting code here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.

urls.py and template folder component tree.

Hi @Derrek2

  • Like @KenWhitesell said, this comes out of the box.
  • I have the same book, and in the chapter 5, there is no custom work that will cause this. Author is explaining the default functionality mostly
  • I suspect you are using the code that is in zip_file/code/ch05a_admin/RiffMates. That code does not include Django installation files. You need to install/setup the Django and then; insert that code in there

Hope this helps.

Thank you for your response. I have looked at the gitHub solution files but did not use them initially. I realize this should come “out of the box” but I must have done something (a typo in Terminal mode is the most likely) that killed some link to the files I need. I tried starting the project from scratch and creating a superuser right off the bat, and in that case the admin-login worked as described right out of the box. I suspect I’ll have to rebuild.

Thanks again.

Ken,

That’s what I expected. I must have done something leading up to that point that messed it up. I expect I’ll have to start over.

Thanks for your response.

Hope I am doing this right. Thanks for your help.

“”"

RiffMates/RiffMates/urls.py

from django.contrib import admin
from django.urls import path, include #1
from home import views as home_views

urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘credits/’, home_views.credits, name=“credits”),
path(‘about/’, home_views.about),
path(‘news/’, home_views.news, name=“news”),
path(‘bands/’, include(“bands.urls”)), #2
]
“”"

you should create templates/admin/login.html.