将Django博客项目集成到HTML网站中

时间:2018-12-10 10:21:26

标签: python django html5

我有一个常规网站,其中使用了HTML5CSS3JQUERY和静态图片。 我还有一个用Django编写的博客,我想将其集成到网站中。 我对Django真的很陌生,所以我想知道哪种方法是最好的使用方法。 我应该将网站代码整合为Django项目的一部分,还是有其他解决方案? 谢谢!

2 个答案:

答案 0 :(得分:0)

您有两种将当前站点与Django集成的方法。

1)您可以使用DjangoRestFramework编写jQuery并使用AJAX HTML发出请求,以便从Django获取内容。

2)您可以将当前的Django文件用作Django项目模板,以呈现const FETCH_CUSTOMERS = gql` query customers($cursor: Int!, $pageNumber: Int!) { customers(cursor: $cursor, pageNumber: $pageNumber) @connection(key: "customers", filter: ["pageNumber"]) { customers { customerID firstname lastname email phone CustomerPhoto { photo } } count } } `; 中的内容。

答案 1 :(得分:0)

您可以使用Django模板。模板定义占位符和基本逻辑的各种位(模板标记),这些逻辑定义了文档的显示方式。通常,模板用于生成HTML,但是Django模板同样能够生成任何基于文本的格式。 如果您使用的模板引擎为“”。它们看起来有些相似。

<html>
<head>
    <title>Ordering notice</title>
</head>
<body>
    <h1>Ordering notice</h1>
    <p>Dear {{ person_name }},</p>
    <p>Thanks for placing an order from {{ company }}. It's scheduled to ship on {{ s\
    hip_date|date:"F j, Y" }}.</p>
    <p>Here are the items you've ordered:</p>
    <ul>
        {% for item in item_list %}
        <li>{{ item }}</li>{% end for %}
    </ul>
    {% if ordered_warranty %}
    <p>Your warranty information will be included in the packaging.</p>
    {% else %}
    <p>
        You didn't order a warranty, so you're on your own when the products inevitably stop working.
    </p>
    {% endif %}
    <p>Sincerely,<br />{{ company }}</p>
</body>
</html>

在此处查看更多详细信息,https://djangobook.com/django-templates/

相关问题