CSS file not Loading

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CSS file not Loading

Suny
Do I need to add STATICFILES_DIRS in settings.py file

TREE STRUCTURE for reference :
.
├── db.sqlite3
├── Fotografie
│   ├── asgi.py
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-38.pyc
│   │   ├── settings.cpython-38.pyc
│   │   ├── urls.cpython-38.pyc
│   │   └── wsgi.cpython-38.pyc
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── Home
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── 0001_initial.cpython-38.pyc
│   │       └── __init__.cpython-38.pyc
│   ├── models.py
│   ├── __pycache__
│   │   ├── admin.cpython-38.pyc
│   │   ├── apps.cpython-38.pyc
│   │   ├── __init__.cpython-38.pyc
│   │   ├── models.cpython-38.pyc
│   │   ├── urls.cpython-38.pyc
│   │   └── views.cpython-38.pyc
│   ├── static
│   │   └── Home
│   │       └── main.css
│   ├── templates
│   │   └── Home
│   │       ├── about.html
│   │       ├── base.html
│   │       ├── contact.html
│   │       └── home.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
└── Users
    ├── admin.py
    ├── apps.py
    ├── __init__.py
    ├── migrations
    │   ├── __init__.py
    │   └── __pycache__
    │       └── __init__.cpython-38.pyc
    ├── models.py
    ├── __pycache__
    │   ├── admin.cpython-38.pyc
    │   ├── apps.cpython-38.pyc
    │   ├── __init__.cpython-38.pyc
    │   ├── models.cpython-38.pyc
    │   ├── urls.cpython-38.pyc
    │   └── views.cpython-38.pyc
    ├── templates
    │   └── Users
    │       └── register.html
    ├── tests.py
    ├── urls.py
    └── views.py


base.html file

{% load static %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="{% static 'Home/main.css' %}">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Annie Use Your Telescope">
    <link href='https://fonts.googleapis.com/css?family=Aclonica' rel='stylesheet'>
<title>Fotografie</title>

</head>

<body>
</body>


css file with main.css name

body {
  background-color: #181818;              /*background of page*/
  color: #FFFFFF;                   /*color of text*/
  margin-top: 1000rem;                /*margin from top*/
}

h1, h2, h3, h4, h5, h6 {
  color: #FFFFFF;
  text-transform: uppercase;
}

ul {
  margin: 0;
}


setting.py file
"""
Django settings for Fotografie project.

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

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

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__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')!e)l*b%z(ywdugroidcrjq4a%&dt7ha2*^amf8s150ndy%+@i'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [                                  #list collector
    'Home.apps.HomeConfig',
    'Users.apps.UsersConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

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 = 'Fotografie.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 = 'Fotografie.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)
# https://docs.djangoproject.com/en/3.0/howto/static-files/ 



STATIC_URL = '/static/'

















--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd79beee-0e17-4ece-a876-0dd79d988d06o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: CSS file not Loading

Clive Bruton
If you are testing the site with manage.py runserver, then you have  
to make sure debug is on. And you have to ensure the app knows where  
the static directories are.


-- Clive

On 28 Jun 2020, at 12:21, Suny wrote:

> Do I need to add STATICFILES_DIRS in settings.py file
>
> TREE STRUCTURE for reference :
> .
> ├── db.sqlite3
> ├── Fotografie
> │   ├── asgi.py
> │   ├── __init__.py
> │   ├── __pycache__
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── settings.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── wsgi.cpython-38.pyc
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── Home
> │   ├── admin.py
> │   ├── apps.py
> │   ├── __init__.py
> │   ├── migrations
> │   │   ├── 0001_initial.py
> │   │   ├── __init__.py
> │   │   └── __pycache__
> │   │       ├── 0001_initial.cpython-38.pyc
> │   │       └── __init__.cpython-38.pyc
> │   ├── models.py
> │   ├── __pycache__
> │   │   ├── admin.cpython-38.pyc
> │   │   ├── apps.cpython-38.pyc
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── models.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── views.cpython-38.pyc
> │   ├── static
> │   │   └── Home
> │   │       └── main.css
> │   ├── templates
> │   │   └── Home
> │   │       ├── about.html
> │   │       ├── base.html
> │   │       ├── contact.html
> │   │       └── home.html
> │   ├── tests.py
> │   ├── urls.py
> │   └── views.py
> ├── manage.py
> └── Users
>     ├── admin.py
>     ├── apps.py
>     ├── __init__.py
>     ├── migrations
>     │   ├── __init__.py
>     │   └── __pycache__
>     │       └── __init__.cpython-38.pyc
>     ├── models.py
>     ├── __pycache__
>     │   ├── admin.cpython-38.pyc
>     │   ├── apps.cpython-38.pyc
>     │   ├── __init__.cpython-38.pyc
>     │   ├── models.cpython-38.pyc
>     │   ├── urls.cpython-38.pyc
>     │   └── views.cpython-38.pyc
>     ├── templates
>     │   └── Users
>     │       └── register.html
>     ├── tests.py
>     ├── urls.py
>     └── views.py
>
>
> base.html file
>
> {% load static %}
> <!DOCTYPE html>
> <html>
> <head>
>     <meta charset="utf-8">
>     <meta name="viewport" content="width=device-width, initial-
> scale=1, shrink-to-fit=no">
>
> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/ 
> bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
> Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"  
> crossorigin="anonymous">
>     <link rel="stylesheet" type="text/css" href="{% static 'Home/
> main.css' %}">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Sofia">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Annie Use Your Telescope">
>     <link href='https://fonts.googleapis.com/css?family=Aclonica' 
> rel='stylesheet'>
> <title>Fotografie</title>
>
> </head>
>
> <body>
> </body>
>
>
> css file with main.css name
>
> body {
>   background-color: #181818;              /*background of page*/
>   color: #FFFFFF;                   /*color of text*/
>   margin-top: 1000rem;                /*margin from top*/
> }
>
> h1, h2, h3, h4, h5, h6 {
>   color: #FFFFFF;
>   text-transform: uppercase;
> }
>
> ul {
>   margin: 0;
> }
>
>
> setting.py file
> """
> Django settings for Fotografie project.
>
> Generated by 'django-admin startproject' using Django 3.0.7.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.0/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.0/ref/settings/
> """
>
> 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__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.0/howto/deployment/ 
> checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = ')!e)l*b%z(ywdugroidcrjq4a%&dt7ha2*^amf8s150ndy%+@i'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [                                  #list collector
>     'Home.apps.HomeConfig',
>     'Users.apps.UsersConfig',
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
> ]
>
> 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 = 'Fotografie.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 = 'Fotografie.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.UserAttributeSimilarityValida
> tor',
>     },
>     {
>         '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)
> # https://docs.djangoproject.com/en/3.0/howto/static-files/
>
>
>
> STATIC_URL = '/static/'
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google  
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,  
> send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/ 
> d/msgid/django-users/cd79beee-0e17-4ece-a876-0dd79d988d06o%
> 40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C4FDA8D2-9A11-43F4-A884-A867716EF898%40indx.co.uk.
Reply | Threaded
Open this post in threaded view
|

Re: CSS file not Loading

Ogunsanya Opeyemi
Yes you need to add STATICFILES_DIRS.
OGUNSANYA OPEYEMI


On Sun, Jun 28, 2020 at 2:58 PM Clive Bruton <[hidden email]> wrote:
If you are testing the site with manage.py runserver, then you have 
to make sure debug is on. And you have to ensure the app knows where 
the static directories are.


-- Clive

On 28 Jun 2020, at 12:21, Suny wrote:

> Do I need to add STATICFILES_DIRS in settings.py file
>
> TREE STRUCTURE for reference :
> .
> ├── db.sqlite3
> ├── Fotografie
> │   ├── asgi.py
> │   ├── __init__.py
> │   ├── __pycache__
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── settings.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── wsgi.cpython-38.pyc
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── Home
> │   ├── admin.py
> │   ├── apps.py
> │   ├── __init__.py
> │   ├── migrations
> │   │   ├── 0001_initial.py
> │   │   ├── __init__.py
> │   │   └── __pycache__
> │   │       ├── 0001_initial.cpython-38.pyc
> │   │       └── __init__.cpython-38.pyc
> │   ├── models.py
> │   ├── __pycache__
> │   │   ├── admin.cpython-38.pyc
> │   │   ├── apps.cpython-38.pyc
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── models.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── views.cpython-38.pyc
> │   ├── static
> │   │   └── Home
> │   │       └── main.css
> │   ├── templates
> │   │   └── Home
> │   │       ├── about.html
> │   │       ├── base.html
> │   │       ├── contact.html
> │   │       └── home.html
> │   ├── tests.py
> │   ├── urls.py
> │   └── views.py
> ├── manage.py
> └── Users
>     ├── admin.py
>     ├── apps.py
>     ├── __init__.py
>     ├── migrations
>     │   ├── __init__.py
>     │   └── __pycache__
>     │       └── __init__.cpython-38.pyc
>     ├── models.py
>     ├── __pycache__
>     │   ├── admin.cpython-38.pyc
>     │   ├── apps.cpython-38.pyc
>     │   ├── __init__.cpython-38.pyc
>     │   ├── models.cpython-38.pyc
>     │   ├── urls.cpython-38.pyc
>     │   └── views.cpython-38.pyc
>     ├── templates
>     │   └── Users
>     │       └── register.html
>     ├── tests.py
>     ├── urls.py
>     └── views.py
>
>
> base.html file
>
> {% load static %}
> <!DOCTYPE html>
> <html>
> <head>
>     <meta charset="utf-8">
>     <meta name="viewport" content="width=device-width, initial-
> scale=1, shrink-to-fit=no">
>
> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/
> bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
> Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
> crossorigin="anonymous">
>     <link rel="stylesheet" type="text/css" href="{% static 'Home/
> main.css' %}">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Sofia">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Annie Use Your Telescope">
>     <link href='https://fonts.googleapis.com/css?family=Aclonica
> rel='stylesheet'>
> <title>Fotografie</title>
>
> </head>
>
> <body>
> </body>
>
>
> css file with main.css name
>
> body {
>   background-color: #181818;              /*background of page*/
>   color: #FFFFFF;                   /*color of text*/
>   margin-top: 1000rem;                /*margin from top*/
> }
>
> h1, h2, h3, h4, h5, h6 {
>   color: #FFFFFF;
>   text-transform: uppercase;
> }
>
> ul {
>   margin: 0;
> }
>
>
> setting.py file
> """
> Django settings for Fotografie project.
>
> Generated by 'django-admin startproject' using Django 3.0.7.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.0/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.0/ref/settings/
> """
>
> 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__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.0/howto/deployment/
> checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = ')!e)l*b%z(ywdugroidcrjq4a%&dt7ha2*^amf8s150ndy%+@i'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [                                  #list collector
>     'Home.apps.HomeConfig',
>     'Users.apps.UsersConfig',
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
> ]
>
> 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 = 'Fotografie.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 = 'Fotografie.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.UserAttributeSimilarityValida
> tor',
>     },
>     {
>         '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)
> # https://docs.djangoproject.com/en/3.0/howto/static-files/
>
>
>
> STATIC_URL = '/static/'
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, 
> send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/
> d/msgid/django-users/cd79beee-0e17-4ece-a876-0dd79d988d06o%
> 40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C4FDA8D2-9A11-43F4-A884-A867716EF898%40indx.co.uk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABJxPrGRq7RTrLqYhOmjrsthuyxtbYsR-kOPAJ_DpZq7UNdaag%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: CSS file not Loading

Hadisur Rahman

put this in your apps sittings on the below.

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')

And then run this code >> python manage.py collectstatic 
then >> python manage.py runserver


Mailtrack Sender notified by
Mailtrack 06/29/20, 08:58:27 PM

On Mon, Jun 29, 2020 at 2:58 PM Ogunsanya Opeyemi <[hidden email]> wrote:
Yes you need to add STATICFILES_DIRS.
OGUNSANYA OPEYEMI


On Sun, Jun 28, 2020 at 2:58 PM Clive Bruton <[hidden email]> wrote:
If you are testing the site with manage.py runserver, then you have 
to make sure debug is on. And you have to ensure the app knows where 
the static directories are.


-- Clive

On 28 Jun 2020, at 12:21, Suny wrote:

> Do I need to add STATICFILES_DIRS in settings.py file
>
> TREE STRUCTURE for reference :
> .
> ├── db.sqlite3
> ├── Fotografie
> │   ├── asgi.py
> │   ├── __init__.py
> │   ├── __pycache__
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── settings.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── wsgi.cpython-38.pyc
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── Home
> │   ├── admin.py
> │   ├── apps.py
> │   ├── __init__.py
> │   ├── migrations
> │   │   ├── 0001_initial.py
> │   │   ├── __init__.py
> │   │   └── __pycache__
> │   │       ├── 0001_initial.cpython-38.pyc
> │   │       └── __init__.cpython-38.pyc
> │   ├── models.py
> │   ├── __pycache__
> │   │   ├── admin.cpython-38.pyc
> │   │   ├── apps.cpython-38.pyc
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── models.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── views.cpython-38.pyc
> │   ├── static
> │   │   └── Home
> │   │       └── main.css
> │   ├── templates
> │   │   └── Home
> │   │       ├── about.html
> │   │       ├── base.html
> │   │       ├── contact.html
> │   │       └── home.html
> │   ├── tests.py
> │   ├── urls.py
> │   └── views.py
> ├── manage.py
> └── Users
>     ├── admin.py
>     ├── apps.py
>     ├── __init__.py
>     ├── migrations
>     │   ├── __init__.py
>     │   └── __pycache__
>     │       └── __init__.cpython-38.pyc
>     ├── models.py
>     ├── __pycache__
>     │   ├── admin.cpython-38.pyc
>     │   ├── apps.cpython-38.pyc
>     │   ├── __init__.cpython-38.pyc
>     │   ├── models.cpython-38.pyc
>     │   ├── urls.cpython-38.pyc
>     │   └── views.cpython-38.pyc
>     ├── templates
>     │   └── Users
>     │       └── register.html
>     ├── tests.py
>     ├── urls.py
>     └── views.py
>
>
> base.html file
>
> {% load static %}
> <!DOCTYPE html>
> <html>
> <head>
>     <meta charset="utf-8">
>     <meta name="viewport" content="width=device-width, initial-
> scale=1, shrink-to-fit=no">
>
> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/
> bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
> Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
> crossorigin="anonymous">
>     <link rel="stylesheet" type="text/css" href="{% static 'Home/
> main.css' %}">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Sofia">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Annie Use Your Telescope">
>     <link href='https://fonts.googleapis.com/css?family=Aclonica
> rel='stylesheet'>
> <title>Fotografie</title>
>
> </head>
>
> <body>
> </body>
>
>
> css file with main.css name
>
> body {
>   background-color: #181818;              /*background of page*/
>   color: #FFFFFF;                   /*color of text*/
>   margin-top: 1000rem;                /*margin from top*/
> }
>
> h1, h2, h3, h4, h5, h6 {
>   color: #FFFFFF;
>   text-transform: uppercase;
> }
>
> ul {
>   margin: 0;
> }
>
>
> setting.py file
> """
> Django settings for Fotografie project.
>
> Generated by 'django-admin startproject' using Django 3.0.7.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.0/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.0/ref/settings/
> """
>
> 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__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.0/howto/deployment/
> checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = ')!e)l*b%z(ywdugroidcrjq4a%&dt7ha2*^amf8s150ndy%+@i'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [                                  #list collector
>     'Home.apps.HomeConfig',
>     'Users.apps.UsersConfig',
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
> ]
>
> 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 = 'Fotografie.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 = 'Fotografie.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.UserAttributeSimilarityValida
> tor',
>     },
>     {
>         '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)
> # https://docs.djangoproject.com/en/3.0/howto/static-files/
>
>
>
> STATIC_URL = '/static/'
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, 
> send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/
> d/msgid/django-users/cd79beee-0e17-4ece-a876-0dd79d988d06o%
> 40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C4FDA8D2-9A11-43F4-A884-A867716EF898%40indx.co.uk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABJxPrGRq7RTrLqYhOmjrsthuyxtbYsR-kOPAJ_DpZq7UNdaag%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOd0vtUX2LJcuvBtvnW62cxr5QASPw4tvvc3D5XJJqkTV6%2BwSg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: CSS file not Loading

Suny
Thanks guys, 
Really appreciate your time and efforts for reviewing and responding back ...
I haven't made any changes to the code, looks like browser was taking the cache file of main.css and was taking a lot of time to update the file.
Just did hard refresh , and it worked .
Thanks again.

On Monday, 29 June 2020 at 20:30:43 UTC+5:30 [hidden email] wrote:

put this in your apps sittings on the below.

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')

And then run this code >> python manage.py collectstatic 
then >> python manage.py runserver


Mailtrack Sender notified by
Mailtrack 06/29/20, 08:58:27 PM

On Mon, Jun 29, 2020 at 2:58 PM Ogunsanya Opeyemi <[hidden email]> wrote:
Yes you need to add STATICFILES_DIRS.
OGUNSANYA OPEYEMI


On Sun, Jun 28, 2020 at 2:58 PM Clive Bruton <[hidden email]> wrote:
If you are testing the site with manage.py runserver, then you have 
to make sure debug is on. And you have to ensure the app knows where 
the static directories are.


-- Clive

On 28 Jun 2020, at 12:21, Suny wrote:

> Do I need to add STATICFILES_DIRS in settings.py file
>
> TREE STRUCTURE for reference :
> .
> ├── db.sqlite3
> ├── Fotografie
> │   ├── asgi.py
> │   ├── __init__.py
> │   ├── __pycache__
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── settings.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── wsgi.cpython-38.pyc
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── Home
> │   ├── admin.py
> │   ├── apps.py
> │   ├── __init__.py
> │   ├── migrations
> │   │   ├── 0001_initial.py
> │   │   ├── __init__.py
> │   │   └── __pycache__
> │   │       ├── 0001_initial.cpython-38.pyc
> │   │       └── __init__.cpython-38.pyc
> │   ├── models.py
> │   ├── __pycache__
> │   │   ├── admin.cpython-38.pyc
> │   │   ├── apps.cpython-38.pyc
> │   │   ├── __init__.cpython-38.pyc
> │   │   ├── models.cpython-38.pyc
> │   │   ├── urls.cpython-38.pyc
> │   │   └── views.cpython-38.pyc
> │   ├── static
> │   │   └── Home
> │   │       └── main.css
> │   ├── templates
> │   │   └── Home
> │   │       ├── about.html
> │   │       ├── base.html
> │   │       ├── contact.html
> │   │       └── home.html
> │   ├── tests.py
> │   ├── urls.py
> │   └── views.py
> ├── manage.py
> └── Users
>     ├── admin.py
>     ├── apps.py
>     ├── __init__.py
>     ├── migrations
>     │   ├── __init__.py
>     │   └── __pycache__
>     │       └── __init__.cpython-38.pyc
>     ├── models.py
>     ├── __pycache__
>     │   ├── admin.cpython-38.pyc
>     │   ├── apps.cpython-38.pyc
>     │   ├── __init__.cpython-38.pyc
>     │   ├── models.cpython-38.pyc
>     │   ├── urls.cpython-38.pyc
>     │   └── views.cpython-38.pyc
>     ├── templates
>     │   └── Users
>     │       └── register.html
>     ├── tests.py
>     ├── urls.py
>     └── views.py
>
>
> base.html file
>
> {% load static %}
> <!DOCTYPE html>
> <html>
> <head>
>     <meta charset="utf-8">
>     <meta name="viewport" content="width=device-width, initial-
> scale=1, shrink-to-fit=no">
>
> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/
> bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
> Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
> crossorigin="anonymous">
>     <link rel="stylesheet" type="text/css" href="{% static 'Home/
> main.css' %}">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Sofia">
>     <link rel="stylesheet" href="https://fonts.googleapis.com/css?
> family=Annie Use Your Telescope">
>     <link href='https://fonts.googleapis.com/css?family=Aclonica
> rel='stylesheet'>
> <title>Fotografie</title>
>
> </head>
>
> <body>
> </body>
>
>
> css file with main.css name
>
> body {
>   background-color: #181818;              /*background of page*/
>   color: #FFFFFF;                   /*color of text*/
>   margin-top: 1000rem;                /*margin from top*/
> }
>
> h1, h2, h3, h4, h5, h6 {
>   color: #FFFFFF;
>   text-transform: uppercase;
> }
>
> ul {
>   margin: 0;
> }
>
>
> setting.py file
> """
> Django settings for Fotografie project.
>
> Generated by 'django-admin startproject' using Django 3.0.7.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.0/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.0/ref/settings/
> """
>
> 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__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.0/howto/deployment/
> checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = ')!e)l*b%z(ywdugroidcrjq4a%&dt7ha2*^amf8s150ndy%+@i'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [                                  #list collector
>     'Home.apps.HomeConfig',
>     'Users.apps.UsersConfig',
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
> ]
>
> 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 = 'Fotografie.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 = 'Fotografie.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.UserAttributeSimilarityValida
> tor',
>     },
>     {
>         '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)
> # https://docs.djangoproject.com/en/3.0/howto/static-files/
>
>
>
> STATIC_URL = '/static/'
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, 
> send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/
> d/msgid/django-users/cd79beee-0e17-4ece-a876-0dd79d988d06o%
> 40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C4FDA8D2-9A11-43F4-A884-A867716EF898%40indx.co.uk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/600679b0-ecb3-4c05-9b78-59219308b10dn%40googlegroups.com.