如何在网站模块中显示我的数据库文章?

2024-04-26 06:06:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我与奥多10工作,我有大量的文章分类,我已经安装了网站模块,现在我想显示我的文章和分类在我的网站的一个网页


Tags: 模块网页网站文章分类
1条回答
网友
1楼 · 发布于 2024-04-26 06:06:05

要构建网站页面,您可以阅读此处的文档[https://www.odoo.com/documentation/10.0/howtos/website.html][1]

继续你必须做的事。你知道吗

第一步是创建带有控制器的链接。像这样

from odoo import http

class Product(http.Controller):
    @http.route('/products/', auth='public')
    def index(self, **kw):
        product_ids = self.env['product.product'].search([])
        return http.request.render('academy.index', {
            'products': product_ids,
        })

第二步是创建模板视图。像这样

<template id="index">
    <title>Products</title>
    <t t-foreach="products" t-as="product">
      <p><t t-esc="product.name"/></p>
    </t>
</template>

这是一个简单的例子。如果您想要更多的信息,您可以阅读文档并查看odoo代码中的示例。你知道吗

相关问题 更多 >