аватар question@mail.ru · 01.01.1970 03:00

CSS connection to Django template

Good day to everyone! I have a “proj” project on Django, the “BLOG” application has been created in it. In the file "" ..../Proj/Blog/Templates/Page.tpl "you need to connect the" Style.css "file" which lies in the same folder. How to register the path to call

  Render_to_Response ( 'page.tpl' . CONTEXT)     

The generated page found CSS file?

аватар answer@mail.ru · 01.01.1970 03:00

If you use the built -in server for development, then you need to place the styles file in the folder with statics (static files). To do this, you need to insert in the urls.py

  ( r '^statika/(? P & lt; Path & gt;.*) $' ,,  'django.Views.static.Serve' ,  { '' document_root ':  '/Path/to/Media' }),  

instead of the word statika, you can write anything, and instead of/path/to/media, the full path to the folder where you want to store statics (for example C:/django_proj/media/for Windows). If you want CSS files to lie with the templates, you need to specify the path to the folder with templates. And then in Page.tpl you need to prescribe

  & Lt; Link Rel =   type  =  href =  ""/statika/style.css ""  & gt;  

instead Statika may be the word that you indicated in urls.

You can read more about the distribution of statics on the developer server.

Latest

Similar