Add Django style sheet
To add stylesheets, the directory of images and javascript files so that Django knows where is everything and directions. One way to solve this is: suppose we have the following hierarchy of directories within the main project.
Monday, January 17, 2011
What A Mri Is Looking For
$ tree templates /
templates / ,
- {'DOCUMENT_ROOT' : settings.STATIC_ROOT + 'templates / css' }),
- ( r'images / (? P \u0026lt;path> .*)$' , ' django.views. static.serve '
settings.STATIC_ROOT +' templates / images'
}), (
| , {'DOCUMENT_ROOT' : settings.STATIC_ROOT + 'templates / js' }) _______________________________________________________ |
=" stylesheet "typeimport settings _______________________________________________________Now we have to define this variable in settings.py . What we do is put as the path to the application: _______________________________________________________
STATIC_ROOT = '/ path / to / app /'
_______________________________________________________ And finally, we need to update the list TEMPLATE_DIRS with the url to the directory template: _______________________________________________________
STATIC_ROOT + 'templates /' , _______________________________________________________
With this, we have all you need to use CSS in your application. When reference is made to pick what style sheet in html, it should point to the root of the template, which would read:
\u0026lt; link
href = " / css / style.css "rel
=" text / css "
/
>
References
Django-doc
0 comments:
Post a Comment