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).
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?)
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'
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).
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.
Update 2021.02.12:
Django Oscar Promotions is an app for Dashboard-editable promotional content in Oscar. It was formerly a part of Oscar core, but has now been separated into a standalone app.
See here: https://github.com/django-oscar/django-oscar-promotions