0

I am trying to deploy the django project to linux server but getting below

error: Bad Request (400)

settings.py

    from pathlib import Path
    import os

    BASE_DIR = Path(__file__).resolve().parent.parent
    DEBUG = False
    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',
        'employee',
    ]

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

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

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

output of collectstatic:

Error: Found another file with the destination path 'css/mystyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path. Please advise if any changes are required.

7
  • Which webserver you are using? Commented Dec 13, 2022 at 6:01
  • I am using Linux Server Commented Dec 13, 2022 at 6:03
  • Linux is OS. Web server means nginx or apache? Commented Dec 13, 2022 at 6:04
  • Yes we are using Nginx Commented Dec 13, 2022 at 6:07
  • Are you able to share you nginx conf? Commented Dec 13, 2022 at 6:08

1 Answer 1

1

Most probably issue is with NGINX server configuraion. You wsgi app service static file but NGINX server not passing outside them on 80/443 port.

Try to change/add NGINX setting as below:

location /static/{
    autoindex on;
    alias /<your_path_to the_static_folder>/;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.