Home > Software engineering >  when I want to see my admin penal in django it give me error not only admin in some urls it give me
when I want to see my admin penal in django it give me error not only admin in some urls it give me

Time:11-01

admin.py:

admin.site.register(models.User)
admin.site.register(models.Teacher)
admin.site.register(models.Student)
admin.site.register(models.CourseCategory)
admin.site.register(models.Course)
admin.site.register(models.Chapter)
admin.site.register(models.Section)
admin.site.register(models.StudentCourseEnrollment)
admin.site.register(models.CourseRating)

settings.py:

DATABASES = {

'default': {
    'ENGINE': 'Django.DB.backends.MySQL,
    'NAME': 'LMSAPI',
    'USER':'admin',
    'PASSWORD':'12341234',
    'HOST':'mydb.cvijitliru7b.ap-northeast-1.rds.amazonaws.com',
    'PORT':'3306',
    'CHARSET': 'utf8',

 }

and this is the error enter image description here

Error traceback:

    TypeError at /admin/login/
can only concatenate str (not "NoneType") to str
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 4.1.2
Exception Type: TypeError
Exception Value:    
can only concatenate str (not "NoneType") to str
Exception Location: C:\Users\DIDAM\Desktop\venv\Lib\site-packages\botocore\auth.py, line 371, in signature
Raised during:  Django.contrib.admin.sites.login
Python Executable:  C:\Users\DIDAM\Desktop\venv\Scripts\python.exe
Python Version: 3.11.0
Python Path:    
['C:\\Users\\DIDAM\\Desktop\\heroku_lms_api',
 'C:\\Python311\\python311.zip',
 'C:\\Python311\\DLLs',
 'C:\\Python311\\Lib',
 'C:\\Python311',
 'C:\\Users\\DIDAM\\Desktop\\venv',
 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages',
 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\win32',
 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\win32\\lib',
 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\Pythonwin']
Server time:    Tue, 01 Nov 2022 06:48:59  0000

CodePudding user response:

stylesheet block should be outside the link tag of html.

In the template replace this:

<link rel="stylesheet" href="{% block stylesheet %} {% static "admin/css/base.css" %} {% endblock %}">

with this:

{% block stylesheet %}
<link rel="stylesheet" href="{% static 'admin/css/base.css' %}">
{% endblock %}

CodePudding user response:

You need to add the ModelAdmin, Documentation

  • Related