how to use css in django 1.9

40 views
Skip to first unread message

dk

unread,
May 12, 2016, 8:03:45 PM5/12/16
to Django users
I am starting with Django 1.9  and  it say that we can have static files  outside the apps,  just for generics for the hole project or inside the apps.

according to the how to, should work  :(

here I uploaded my mini project,
when I put this address the code works  but doesn't really use the css

I also try to put a folder call static inside the app and the css file inside,  but same issue.     what should be the proper way to set up the css?

thanks guys, I appreciate it. =)
testing_django_19.zip

dk

unread,
May 13, 2016, 1:37:41 AM5/13/16
to Django users
 or what would be the best way to "print" the path for static?

Mike Dewhirst

unread,
May 13, 2016, 3:48:36 AM5/13/16
to django...@googlegroups.com
On 13/05/2016 3:37 PM, dk wrote:
> Â or what would be the best way to "print" the path for static?

When I was starting out it was all quite difficult so I added the
following to my (dev only) settings to reveal where all my directories
were hiding ...

BTW, dbhost below is a list of database host settings

print("\ndev settings")
print(('\nPython: %s' % sys.version[0:3]))
from django import get_version
print(('Django: %s' % get_version()))
print(('Database: %s' % DATABASES['default']['HOST']))
print(('%s' % dbhost[4]))
from datetime import datetime as dtm
ttm = "%s:%02d:%02d" % (dtm.now().hour, dtm.now().minute, dtm.now().second)
print(("%s\n" % ttm))

print(('BASE_DIR = %s %s' % (BASE_DIR, '(project root)')))
print(('SETTINGS_DIR = %s' % SETTINGS_DIR))
print(('MEDIA_ROOT = %s %s' % (MEDIA_ROOT, '(store
uploaded images)')))
print(('MEDIA_URL = <website>%s %s' %
(MEDIA_URL, '(serve uploaded images)')))
print(('STATIC_ROOT = %s %s' % (STATIC_ROOT,
'(collectstatic dest)')))
print(('STATIC_URL = <website>%s %s' %
(STATIC_URL, '(serve css, js etc)')))
for i in enumerate(STATICFILES_DIRS, 1):
print(('STATICFILES_DIRS# %s = %s' % i))
for i in enumerate(TEMPLATE_DIRS, 1):
print(('TEMPLATE_DIRS# %s = %s' % i))




>
>
>
> On Thursday, May 12, 2016 at 5:03:45 PM UTC-7, dk wrote:
>
> I am starting with Django 1.9 and it say that we can have static
> files outside the apps, just for generics for the hole project
> or inside the apps.
>
> according to the how to, should work :(
>
> here I uploaded my mini project,
> when I put this address the code works but doesn't really use the css
> http://127.0.0.1:8000/my_app/
>
> I also try to put a folder call static inside the app and the css
> file inside, but same issue.    what should be the proper way
> to set up the css?
>
> thanks guys, I appreciate it. =)
>
> --
> 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...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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/c6aaf20f-3dbc-4f95-949b-9d4080d5bcca%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c6aaf20f-3dbc-4f95-949b-9d4080d5bcca%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

dk

unread,
May 13, 2016, 3:56:02 AM5/13/16
to Django users
add this to the settings.


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



Reply all
Reply to author
Forward
0 new messages