Thursday, July 14, 2016

Re: template include for Django 1.8

On 14/07/2016 4:53 PM, James Schneider wrote:
> On Jul 13, 2016 6:54 PM, "Mike Dewhirst" <miked@dewhirst.com.au
> <mailto:miked@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.

It is used elsewhere too

>
>> {% 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

Sorry about that. Missed it when scanning the index list on the right of
the page.

>
>> 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.

Includes the css file thanks James but it doesn't satisfy the pdf software.

Back to the embedded styles copied and pasted.

Oh well.

Mike

>
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUCGXTfH3hg6G105cLbParD1fD2iijbUtE3uJ682E1hNg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
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/846fa131-6270-2de5-eebf-73ee6faf6433%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment