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.
-- 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+unsubscribe@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.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment