1
votes

"Error:-1" is show when my DEBUG=False and "Error:-2" is show when my DEBUG=True.

I will use python 3.7.7 and django 3.0.4 .

my settings.py file is:-



DEBUG = False

ALLOWED_HOSTS = ["*"] 

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'home.apps.HomeConfig',
]

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 = '***************'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        '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 = '*************************'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

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


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
#

#for uploaded image

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

#end of uploded image


STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    # '/static/',
]

This is "Error:1" .... [ When DEBUG=False ]


[15/Mar/2020 11:14:56] "GET /admin/login/?next=/admin/ HTTP/1.1" 500 4712
[15/Mar/2020 11:14:56] "GET /static/js/jquery-3.2.1.min.js HTTP/1.1" 304 0
[15/Mar/2020 11:14:56] "GET /admin/login/js/main2.js HTTP/1.1" 404 21440
[15/Mar/2020 11:14:56] "GET /static/js/bootstrap.min.js HTTP/1.1" 304 0
[15/Mar/2020 11:14:56] "GET /admin/login/js/main.js HTTP/1.1" 404 21440
[15/Mar/2020 11:14:56] "GET /static/js/owl.carousel.min.js HTTP/1.1" 304 0
[15/Mar/2020 11:14:56] "GET /static/js/jquery.marquee.min.js HTTP/1.1" 304 0
[15/Mar/2020 11:14:56] "GET /static/js/main.js HTTP/1.1" 304 0
[15/Mar/2020 11:14:56] "GET /admin/login/js/main.js HTTP/1.1" 404 21440

This is "Error:-2" ... [ When DEBUG=True ]

But at time of ' DEBUG=True ' my admin page is open but it gives below error in terminal.

[15/Mar/2020 11:15:51] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1913

When ever i try to open '/admin/' in my browser i will gives an error, But my home page [ 127.0.0.1:8000 ] it's working properly.

thanks in advance.

1
You might be hitting this bug. Try upgrading to the latest 3.7.x (currently 3.7.7), or 3.8.x if you can. - Alasdair
I will upgrade python to 3.7.7 but still it gives an error, Thank you for your reply. - shubham
Sorry, I don’t have any more suggestions. If the error message is different now, please update your question - it might make it easier to see what the problem is. - Alasdair
Yes, I will update my question with new error. - shubham

1 Answers

1
votes

**Finally error can solve ..**

we can remove only three line from settings.py

1> django_heroku.settings(locals()) this line is require for deployment Django app on Heroku.

2> STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

3> MIDDLEWARE = [ ... 'whitenoise.middleware.WhiteNoiseMiddleware', ]

2nd and 3rd line are use for serve static files on website when DEBUG=False.

after removing this three line error can solve and, It will run perfectly without any error.

thank you and special thank you for Alasdair .