在django-oscar主页上添加产品 [英] Adding products in django-oscar homepage

查看:118
本文介绍了在django-oscar主页上添加产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找在首页中展示产品的最佳方法。我正在使用django-oscar附带的沙箱构建我的网站(我是从Github克隆项目的。)。

I'm trying to figure out the best way to display products inside my homepage. I'm building my website using the sandbox that already comes with django-oscar (I cloned the project from Github).

我发现默认首页由促销应用。但是,我的产品仅在 http:// localhost:8000 / catalogue (由 catalogue控制'app)。

I discovered that the default homepage is controlled by 'promotions' app. However, my products are just being displayed inside 'http://localhost:8000/catalogue' (controlled by 'catalogue' app).

是否可以在首页中显示商品?还是我必须更改控制主页的默认应用程序? (在这种情况下,我该怎么办?)

Is there a way to display the products in my homepage? Or will I have to change the default app that controls the homepage? (in this case, how can I do that?)

编辑1:我相信我找到了解决方案。您可以按照教程如何自定义现有视图;但是,您需要进行一些更改,因此您的代码必须如下所示:

EDIT 1: I believe that I found a solution. You can follow the tutorial How to Customize an Existing View; however, you need to make some changes, so your code must looks like this:

 from oscar.apps.catalogue.views import CatalogueView

 class HomeView(CatalogueView):
     template_name = 'promotions/home.html'

这样,您将可以访问 promotions / home.html中的产品。我不确定这是否是实现此目标的最佳方法,如果其他人可以替代此解决方案,请发表评论。

This way you will have access to the products in your 'promotions/home.html'. I'm not sure if it is the best way to implement this, if someone else has an alternative to this solution, please comment.

推荐答案

为此,奥斯卡有一个名为 促销 。此应用程序负责在首页上呈现内容块,尤其是(据我所知,您可以从文档中找到)。

For this purpose Oscar has an app called promotions. This application is responsible for rendering blocks of content on the homepage, among other things (as I can see you found out from the documentation).

通常,您会使用促销应用程序将产品和其他类型的内容添加到页面。可以在控制台中使用 Content块 Content 菜单下找到。

Usually you would use the promotion app to add products and other types of content to a page. This can be done from the Dashboard, using Content blocks, which can be found under the Content menu.

您可以定义几种促销类型(单个产品,自动产品和手工挑选的产品列表等)。

There are a few types of promotions that you can define (single product, automatic, and hand picked product list, and others).

定义促销后,您将能够将其与页面路线相关联,在您的情况下,该页面路线应为 /

After defining your promotion, you will be able to associate it with a page route, which in your case should be /.

如果您选择更改此行为,则文档应该提供一个很好的起点。

If you choose to change this behaviour, then the documentation should provide a good starting point.

这篇关于在django-oscar主页上添加产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆