나는 DEBUG 상태에 있으며 PrinceXML을 사용하여 HTML 페이지를 PDF로 렌더링하려고합니다. 내 주요 HTML에서Django에 포함 된 HTML에 정적 파일을로드해야합니까?
내가 가진 :
@page {
margin-left: 0.8cm;
margin-right: 0.8cm;
margin-bottom: 2cm;
margin-top: 4cm;
@top-left {
margin-left: -0.6cm;
margin-right: -0.6cm;
content: url({% static "url" %});
}
@bottom-right {
border-top: solid 1px #bbb;
margin-top: 0.4cm;
vertical-align: middle;
font-size: 8pt;
content: counter(page) "/" counter(pages)
}
@bottom-center {
border-top: solid 1px #bbb;
margin-top: 0.4cm;
vertical-align: middle;
font-size: 8pt;
content: "{% now 'j.m.Y' %}"
}
@bottom-left {
border-top: solid 1px #bbb;
margin-top: 0.4cm;
padding-right: 2cm;
vertical-align: middle;
font-size: 8pt;
content: "footer info"
}
size: A4
}
html {
font-family: Arial, Verdana, Geneva, Helvetica, sans-serif ;
}
div.page-header {
page-break-before: always
}
이
내 질문은 :
{% extends "base.html" %}
{% load staticfiles %}
{% load url from future %}
{% block title %}Title{% endblock %}
{% block style %}
{% include "style.html" %}
<link rel="stylesheet" type="text/css" href="{% static "more.style.css" %}"/>
{% endblock %}
{% block branding %}<a class='brand' rel="nofollow" href="{% url 'url' %}">Brand</a>{% endblock %}
{% block userlinks %}
{% if user.is_authenticated %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{ user }}
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="{% url 'generate-pdf' %}">Get the doc in pdf</a></li>
<li><a href="{% url 'dashboard.views.index' %}">Home</a></li>
<li><a href="{% url 'logout' %}">Logout</a></li>
</ul>
</li>
{% endif %}
{% endblock %}
내 style.html PDF를 생성하는 데 필요한 PrinceXML이 정보입니다 : 이미 {% load staticfiles %}에서 HTML에 스타일을 포함하기 때문에, style.html에 광고를 다시 게재 하시겠습니까?
Django docs에서 말한 것처럼 include는 main.html의 컨텍스트로 style.html을 렌더링하지만 staticfiles 라이브러리는 컨텍스트의 일부가 아니기 때문에 내 생각에는 yes입니다. 내가 맞습니까? Django docs에서
문서에서이 내용을 읽었지만 다음 질문에 답하지 못했습니다. 포함 된 HTML에 공유되는 유일한 것은 컨텍스트 변수입니까? – Laurent
맞습니다. :) – Filly
Filly 감사합니다! – Laurent