fabiocaccamo / django-admin-interface

:superhero: :zap: django's default admin interface with superpowers - customizable themes, popup windows replaced by modals and many other features.
MIT License
1.79k stars 180 forks source link

Modal window not closing after saving #256

Closed ek-gonzalez closed 1 year ago

ek-gonzalez commented 1 year ago

Python version Python 3.7.16

Django version 3.2.17

Package version 0.24.2

Current behavior (bug description) When I create an object with a foreign key through the related class page, the popup is not closing after creating it.

image

merwok commented 1 year ago

This looks like XSS protection issue, see https://github.com/fabiocaccamo/django-admin-interface#installation

ek-gonzalez commented 1 year ago

This looks like XSS protection issue, see https://github.com/fabiocaccamo/django-admin-interface#installation

Hey @merwok, this is my settings.py:


Django settings for project.

Generated by 'django-admin startproject' using Django 3.2.17.

from pathlib import Path
import os

BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production

SECRET_KEY = '--redacted--'

DEBUG = True

ALLOWED_HOSTS = ['*']

INSTALLED_APPS = [
    "admin_interface",
    "colorfield",
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    '(appName).apps.(appName)Config',
]

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 = '(projectname).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 = '(appname).wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

if 'RDS_HOSTNAME' in os.environ:
    DATABASES = {
        'default': {
         --REDACTED--
        }
    }

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',
    },
]

X_FRAME_OPTIONS = "SAMEORIGIN"
SILENCED_SYSTEM_CHECKS = ["security.W019"]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = 'static'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
fabiocaccamo commented 1 year ago

@ek-gonzalez from what I can see in your screenshot, the popup_response.js file that raises the error is not the customised one, and since the installed apps ordering is correct, the only possible reason is that you forgot to run python manage.py collectstatic.

ek-gonzalez commented 1 year ago

image

The original .js were not removed automatically, so the files in the static folder were not the ones of this repository.

fabiocaccamo commented 1 year ago

@ek-gonzalez probably python manage.py collectstatic is not enough in these cases because it doesn't replace existing files, so the right command to call is python manage.py collectstatic --clear, I update the README.