首页 文章

在HTML网站中集成Django博客项目

提问于
浏览
1

我有一个常规网站,其中使用了 HTML5CSS3JQUERY 和静态图像 . 我也有一个写在 Django 的博客,我想将它整合到网站上 . 我是 Django 的新手,所以我想知道哪种方法最好用 . 我应该将网站代码集成为 Django 项目的一部分还是有其他一些解决方案?谢谢!

2 回答

  • 0

    您有两种方法可以将当前站点与Django集成 .

    1)您可以使用 DjangoRestFramework 编写 API 并使用 jQuery AJAX 发出请求以从Django获取内容 .

    2)您可以使用当前的 HTML 文件作为 Django 项目模板来呈现 Django 中的内容 .

  • 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,
    {{ company }}</p> </body> </html>

    点击这里查看更多详情https://djangobook.com/django-templates/

相关问题