On Jul 13, 2016 6:54 PM, "Mike Dewhirst" <mi...@dewhirst.com.au> wrote:
>
> I need to include the contents of a css file in my template [1]
>
> The css content needs to exist within <style type="text/css"> and
</style> tags so that the pdf output software I'm using can see the styles.
>
> I can get the correct effect by copying and pasting the contents of the
css file into the template but that way madness lies!
>

Not necessarily. If that's the only location where this CSS is used, then
it may be appropriate to include it directly in the template.

> {% include %} exists but seems designed for other templates. And I can't
find it in the docs.
>

https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include

> Is there a way to include the content of a css file?
>

I'm reasonably confident that the include tag will do exactly what you want
it to do. Django is not going to care whether it is including HTML or CSS
or a recipe for chocolate French fries. It'll only care if other template
tags are included and cause other issues, but otherwise the content is
irrelevant. All the template system does is generate a text file,
ultimately.

I'm assuming this CSS file is located in your template directories and not
in your static files area so that the template system can find it.

-James

-- 
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/CA%2Be%2BciUCGXTfH3hg6G105cLbParD1fD2iijbUtE3uJ682E1hNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to