I use below settings. For this to work you have to create 2 folders inside
the folder where manage.py is located - "*static*" and "*media*".
Use below settings and run the *collectstatic* command once again and see
if it works for you.


STATIC_URL = '/static/'
MEDIA_URL = '/media/'

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]

STATIC_ROOT = os.path.join(BASE_DIR, "static/")
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, Jun 1, 2019 at 4:54 PM Ankhi Roy <montip...@gmail.com> wrote:

> Hey,
>
>
> So I have made the following changes and Django can now read static CSS
> file now there is no more 404 while loading the static css file. However,
> on the web browser, the output does not reflect css properties like header
> color or header alignment.
>
> I have run python3 manage.py collectstatic(since i am using python3) got
> the following output -
>
> "0 static files copied to
> '/home/username/project/file:/home/username/project/app/templates/static',
> 120 unmodified." -- Not sure what this means, does it means Django is still
> unable to fetch the CSS static file? I am guessing this as I still cannot
> see any CSS specific change on my view. I would like to confirm the cause.
>
> I am using ubuntu linux 18.04, Django-admin - 2.2.1 and Pycharm Community
> IDE.
>
> so my settings.py file has -
>
> STATIC_ROOT = 'file:///home/username/project/app/templates/static/'
> STATIC_URL = 'file:///home/username/project/app/templates/static/'
> BASE_DIR1 = '/home/username/project/app/templates/'
> STATICFILES_DIRS = [
>
>     os.path.join(BASE_DIR1, 'static'),
>
> ]
>
> My app/View.py file -
>
> <!DOCTYPE html>
>     <head>
>     {%load static%}
>     <link rel="stylesheet" href = "{%static 'CSS/index.css'%}" type =
> "text/css">
>    <!-- <style>
>     h1 {
>     color: blue;
>     text-align: center;
>         }
>     </style>-->  #Inline css is working the problem is while loading
> external css file by Django.
>     </head>
>     <body>
>     <h1> Hello World!!!</h1>
>     </body>
> </html>
>
>
> My External index.css file -
>
> h1 {
>     color: blue;
>     text-align: center;
>     }
>
> Please help and guide.
>
> Thanks
>
> Ankhi
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b5216c4a-81a6-4d7f-a890-ad8faf7d840d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b5216c4a-81a6-4d7f-a890-ad8faf7d840d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMKMUjs%3D5GtV3DnMN%3DXJm2dB_%2B3NTgubqjPFfva6Hjx2%2B8RU-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to