Static images are working but static CSS is not working SS attached

25 views
Skip to first unread message

Param Saini

unread,
Jul 13, 2018, 3:07:48 PM7/13/18
to Django users
Static Images are working perfectly in Django .. but when i try to use static CSS or evev open Django admin panel . CSS is not implemented there 

please help on priority
Picture1.png

Kasper Laudrup

unread,
Jul 13, 2018, 4:46:36 PM7/13/18
to django...@googlegroups.com
Hi Param,

On 2018-07-13 16:29, Param Saini wrote:
> Static Images are working perfectly in Django .. but when i try to use
> static CSS or evev open Django admin panel . CSS is not implemented there
>

Are you running the development server or is this in production?

If it is in production, have you set up your web server to serve the
static files correctly, added the necessary settings to settings.py and
run the 'collectstatic' command?

There's quite a lot of documentation on how to server static files in
production out there. A simple google search should give you tons of hits.

If you need more help, please post your web server configuration as well
as your settings.py file.

Kind regards,

Kasper Laudrup

Param Saini

unread,
Jul 14, 2018, 7:16:07 AM7/14/18
to Django users



I just started working on python so copying settings.py file contents below : 
and regarding production and development server i have no idea ... i just run it on my Laptop by using python manage.py runserver command 

Settings.py file :
"""
Django settings for firstproject project.

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

For more information on this file, see

For the full list of settings and their values, see
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR=os.path.join(BASE_DIR,"templates")
STATIC_DIR=os.path.join(BASE_DIR,"static")

#print(TEMPLATE_DIR)
# Quick-start development settings - unsuitable for production

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '@8bm15dgxr#74ao@8i$5p=@7rk(^2%vtcehl*(8#ltz$46g*^v'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'first_app'
]

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 = 'firstproject.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR,],
        '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 = 'firstproject.wsgi.application'


# Database

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


# Password validation

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'
STATIC_ROOT=''
STATICFILES_DIRS = [
STATIC_DIR,
]


wsgi.py
"""
WSGI config for firstproject project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "firstproject.settings")

application = get_wsgi_application()

Kasper Laudrup

unread,
Jul 14, 2018, 6:10:48 PM7/14/18
to django...@googlegroups.com
Hi Param,

On 2018-07-14 09:16, Param Saini wrote:
>
> I just started working on python so copying settings.py file contents
> below :
> and regarding production and development server i have no idea ... i
> just run it on my Laptop by using python manage.py runserver command
>

Then you are running in development mode with the development server.

> Settings.py file :

That looks fine to me, but I'm far from an expert on Django. Maybe
someone else on this list can help?

Kind regards,

Kasper Laudrup

Param Saini

unread,
Jul 16, 2018, 11:51:44 AM7/16/18
to Django users
Reply all
Reply to author
Forward
0 new messages