My ckeditor-uploaded image doesn't show up in the post unless I restart the django app from cpanel

42 Views Asked by At

`My ckeditor uploaded image doesn't show up unless I restart the django app from cpanel

my ckeditor-imported post page works fine in local server, BUT in the production server after i upload an image to server **FIRST **image doesnt in appear post layout (it used to in local server)

in local server image would show up here

in editor i used to have the image here in the editor

it doesn't appear in my post neither...

....unless i restart it from cpanel

after i restarted the app from cpanel, it started to work fine

i have the following settings.py code:

from pathlib import Path
import os

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

SECRET_KEY = 'x'
DEBUG = False
ALLOWED_HOSTS = ['cozumdefteri.com']

INSTALLED_APPS = [
    'gonderiyaz.apps.GonderiyazConfig',
    'ckeditor',
    'ckeditor_uploader',
    'mebsci.apps.MebsciConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

CKEDITOR_UPLOAD_PATH = 'static/uploads/'

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    '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 = 'cozumdefteri.urls'

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

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 = 'cozumdefteri.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_TZ = True

STATIC_URL = 'static/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'mebsci.MebsciModel'

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 300,
        'width': '100%',
        'allowedContent': True,
    },
}

As a soln attempt, i set the STATIC_URL to public_html (thinking this folder will be instantlt accessible), then uploads folder to public_html/uploads, in that case images was beineg uploaded to given dir, but even after the restart of the app, images wasn't loading on the html image`

0

There are 0 best solutions below