Admin interface appears broken.

I have a production server (Debian stretch) and a development server (Unbuntu 20-04 xfce).
In both cases, Django is used in a virtualenv. However, on the production server, the site is served by apache and by the development included web server on the development server. Both virtualenv’s are up to date.
My problem:

  • on the production server, everything is ok
  • on the development server, the admin interface appears completely broken). And this appeared only some weeks ago. Also, restoring an old version (from a borg save) does not suppress the problem.
    Any idea? this is the list of the packages included in the virtualenv:
    Django, dhango-bootsrap4, django extensions; pyllow, xlwt, pypandoc, unidecode, xlwt.
2 Likes

We may need more specific information, like which version of Django you’re running, and exactly what do you mean by “broken”.

But I’ll take a first stab at a common problem I’ve seen reported here - check your browser’s cache. When you go to your admin site, either clear the cache or do a force-reload (shift-F5 or shift-reload). There have been some style changes made to the admin, and it’s tripped up a couple people.

Ken

2 Likes

Thanks for your quick answer.

  1. the django packages versions
    Django 3.1.1
    django-bootstrap4 2.2.0
    django-extensions 3.0.8
  2. when going to 127.0.0.1:8000/admin/ everything look correct:

but:
3) clicking on any item of the menu (for example “Utilisateurs” = Users), shows this, which cannot be used…

Thanks a lot!

1 Like

I must add that I have emptied the cache in firefox, and that the same problem appears with iridiem browser.

1 Like

Same thing - on the detail page, do the shift-reload (or shift-f5)

no change after reload…

hélas…

t.d.

Hmmm…

In your virtualenv, are you running with debug True, or False? If debug False, how are you serving static files?

(The image posted is clearly symptomatic of using the old admin css files with the newer release of Django. My gut tells me something has gotten stepped on, and it’s just an issue of finding out what.)

I think at this point, I’d try one or more of the following:

  1. Create a new virtualenv and try it there
  2. Create a minimal new project and run it in the current virtualenv
  3. Start digging around in your browser’s developer tools to see where it’s getting the css from that is being applied to the admin page.
  4. Verify that the css files in the admin project are from the current version
1 Like

Thanks!
first experience.

  • I have created a new virtualenv, with only django installed. pip list says:
    asgiref 3.2.10
    Django 3.1.1
    pip 20.0.2
    pkg-resources 0.0.0
    pytz 2020.1
    setuptools 44.0.0
    sqlparse 0.3.1
  • and I created a very minimal Django app, called App.
    class App(models.Model):
    num= models.IntegerField()
    name= models.CharField(max_length=500)
    class AppAdmin(admin.ModelAdmin):
    list_display=(“num”,“name”)
    search_fields= (“num”,“name”)
    search_fields= (“num”,“name”)
    admin.site.register(App)
    -> Now after migrations, check, I run (with debug = True -as always-) ./manage.py runserver
    …ok. Going to 127.0.0.1:8000/admin shows exactly what I was waiting for, with Apps, Groups, Users and no more.
    -> Clicking an “Apps”, I go to 127.0.0.1:8000/App0/app/ and there what I see does not convince me;
    that is to say, I not only see the Apps interface, but also Groups, Users…and the real Apps admin interface below. In my “real” application, I have about 20 installed apps: if this is the normal behavior , i cannot use it .
    Here is a screen of what I got with Apps:

    -> concerning my “real” application, I found that I have a static/admin/ directory with css, js … inside.
    Actually, as everybody I learned Django and developped this site in a hurry… There remain probably beginner’s mistakes. But removieng this static/admin directory did not change anything. More investigations are needed.

Thank you very, very much.
t.d.

1 Like

I can assure you that this is not normal behavior. I have created a project from the information posted here, and do not see anything like what you’re displaying.

What I find curious is that you’re showing a url with “App0”, but you don’t mention / show any app by that name.

Can you post the ROOT_URL setting from your settings file, and the contents of the urls.py being referenced by it?

(Actually, it might be helpful to see your complete settings file, other than the “private” settings such as the secret key and database credentials. There may be other files we’re going to need to see - something is clearly being retrieved from the wrong place(s).)

(Side note: when posting code, please enclose the code between lines consisting of three backtick - ` characters. This means you’ll have a line that is only ```, then your lines of code, then another line of ```. Make sure you use the backtick - ` and not the apostrophe - '. This will display your code properly formatted.)

Thanks again for the help. I fear it will be a stupid problem , abeginners (in Django) fault at the end.
Here is my settings.py, with comment lines suppressed:


from pathlib import Path
BASE_DIR = Path(file).resolve().parent.parent
SECRET_KEY = ‘=pd&csll^%-bnmz2lr)be7@%3%2)jz0fbw6+gdpk93qxh824k^’
DEBUG = True
ALLOWED_HOSTS = [‘127.0.0.1’]
INSTALLED_APPS = [
‘App0.apps.App0Config’,
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
]
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
]
ROOT_URLCONF = ‘Test.urls’
TEMPLATES = [
{
‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,
‘DIRS’: [],
‘APP_DIRS’: True,
‘OPTIONS’: {
‘context_processors’: [
‘django.template.context_processors.debug’,
‘django.template.context_processors.request’,
‘django.contrib.auth.context_processors.auth’,
‘django.contrib.messages.context_processors.messages’,
],
},
},
]
WSGI_APPLICATION = ‘Test.wsgi.application’
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.sqlite3’,
‘NAME’: BASE_DIR / ‘db.sqlite3’,
}
}
AUTH_PASSWORD_VALIDATORS = [
{
‘NAME’: ‘django.contrib.auth.password_validation.UserAttributeSimilarityValidator’,
},
{
‘NAME’: ‘django.contrib.auth.password_validation.MinimumLengthValidator’,
},
{
‘NAME’: ‘django.contrib.auth.password_validation.CommonPasswordValidator’,
},
{
‘NAME’: ‘django.contrib.auth.password_validation.NumericPasswordValidator’,
},
]
LANGUAGE_CODE = ‘en-us’
TIME_ZONE = ‘UTC’
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = ‘/static/’


and here is the urls.py:


from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path(‘admin/’, admin.site.urls),
path("", include(‘App0.urls’)),
]


and App0/urls.py:


from django.urls import path
from . import views
urlpatterns = [
path(’’, views.show, name=‘show’),
]


Please edit your post to surround the code blocks with lines of ```, this will make sure that the code retains its formatting and that any special characters aren’t hidden or transformed.

Ok I apologize…

settings.py

from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = '=pd&csll^%-bnmz2lr)be7@%3%2)jz0fbw6+gdpk93qxh824k^'
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1']
INSTALLED_APPS = [
    'App0.apps.App0Config',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'Test.urls'
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
WSGI_APPLICATION = 'Test.wsgi.application'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}
AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'

urls.py:

from django.contrib import admin
from django.urls import path,include

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

and App0/urls.py:

from django.urls import path

from . import views
urlpatterns = [
    path('', views.show, name='show'),
]
1 Like

No need to apologize - it’s all a learning process.

Can you copy/paste the text from your runserver output when you’re in the admin? I’m looking for output that would look something like this (fenced by lines of three backticks), specifically including the page that isn’t being displayed correctly when reloaded with a shift-f5 or shift-reload:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 14, 2020 - 16:07:42
Django version 3.0.10, using settings 'ft.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[14/Sep/2020 16:08:41] "GET / HTTP/1.1" 200 16351
[14/Sep/2020 16:08:47] "GET /admin/ HTTP/1.1" 200 3998
[14/Sep/2020 16:08:52] "GET /admin/App/app/ HTTP/1.1" 200 4293
[14/Sep/2020 16:08:52] "GET /admin/jsi18n/ HTTP/1.1" 200 3223
[14/Sep/2020 16:08:56] "GET /admin/App/app/1/change/ HTTP/1.1" 200 4629
[14/Sep/2020 16:08:56] "GET /admin/jsi18n/ HTTP/1.1" 200 3223
[14/Sep/2020 16:09:08] "GET /admin/App/app/ HTTP/1.1" 200 4293
[14/Sep/2020 16:09:08] "GET /admin/jsi18n/ HTTP/1.1" 200 3223
[14/Sep/2020 16:09:11] "GET /admin/App/app/ HTTP/1.1" 200 4293
[14/Sep/2020 16:09:11] "GET /admin/jsi18n/ HTTP/1.1" 200 3223
[14/Sep/2020 16:09:11] "GET /static/admin/css/changelists.css HTTP/1.1" 200 6190
[14/Sep/2020 16:09:11] "GET /static/admin/css/base.css HTTP/1.1" 200 16378
[14/Sep/2020 16:09:11] "GET /static/admin/js/jquery.init.js HTTP/1.1" 200 363
[14/Sep/2020 16:09:11] "GET /static/admin/js/core.js HTTP/1.1" 200 5723
[14/Sep/2020 16:09:11] "GET /static/admin/css/responsive.css HTTP/1.1" 200 18052
[14/Sep/2020 16:09:11] "GET /static/admin/js/vendor/jquery/jquery.js HTTP/1.1" 200 287630
[14/Sep/2020 16:09:11] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[14/Sep/2020 16:09:11] "GET /static/admin/js/admin/RelatedObjectLookups.js HTTP/1.1" 200 6918
[14/Sep/2020 16:09:11] "GET /static/admin/js/actions.js HTTP/1.1" 200 6766
[14/Sep/2020 16:09:11] "GET /static/admin/js/prepopulate.js HTTP/1.1" 200 1530
[14/Sep/2020 16:09:11] "GET /static/admin/js/urlify.js HTTP/1.1" 200 8941
[14/Sep/2020 16:09:11] "GET /static/admin/js/vendor/xregexp/xregexp.js HTTP/1.1" 200 128820
[14/Sep/2020 16:09:11] "GET /static/admin/img/tooltag-add.svg HTTP/1.1" 200 331
[14/Sep/2020 16:09:11] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[14/Sep/2020 16:09:11] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
[14/Sep/2020 16:09:11] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184
Not Found: /favicon.ico
[14/Sep/2020 16:09:11] "GET /favicon.ico HTTP/1.1" 404 1968
1 Like

The output seems very short.
-> launching webserver
-> going to 127.0.0.1/admin
-> click “Apps0”

 ./manage.py runserver -v 3
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 14, 2020 - 16:28:11
Django version 3.1.1, using settings 'Test.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[14/Sep/2020 16:28:19] "GET / HTTP/1.1" 200 287
[14/Sep/2020 16:28:27] "GET /admin/ HTTP/1.1" 200 5875
[14/Sep/2020 16:28:30] "GET /admin/App0/app/ HTTP/1.1" 200 6149
[14/Sep/2020 16:28:30] "GET /admin/jsi18n/ HTTP/1.1" 200 3187

(exactly the same output without -v 3)
yours
t.

This is indicating that you’re getting the css from cache.

Do it with the shift-reload or shift-F5 - you should be seeing all the css files being loaded.

You should also see the same results if you try this from a private or incognito window.

1 Like

Thierry_Dumont ; Did you find a solution to your problem because I have the same problem as yours.?

Had the same problem, as @KenWhitesell suggested, it was css from cache

so how did you solve this problem (of Css cache)

please, how did you solved this probleme (css cache)?

please, did you find a solution of your probleme?i have same yours probleme… :face_with_thermometer: :sob: