Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Creating my own product

75 views
Skip to first unread message

Hugo

unread,
Nov 13, 2024, 10:31:51 AM11/13/24
to django-oscar
I  see in the guide:

Suppose you want to add a video_url field to the core product model.
...
Next, you can modify the Product model through subclassing:

# yourproject/catalogue/models.py
from django.db import models
from oscar.apps.catalogue.abstract_models import AbstractProduct

class
Product(AbstractProduct):
    video_url = models.URLField()

from
oscar.apps.catalogue.models import *

I have some questions,
First, is that I tried it, and don't see the 'video_url' in the product, so, something left in the doucmentation.
And my  other questions is, can't I create other classes, like DigitalProduct?

Aaron Jack

unread,
Nov 14, 2024, 12:54:28 PM11/14/24
to django-oscar
I think the idea is to have 1 product model, then multiple product classes inside oscar, to define different types of products, i.e. t shirts, cd's, dvd's

To add the custom field on the product model to the oscar dashboard you need to fork the dashboard app and in catalogue.forms.py add something like this:


class ProductForm(base_forms.ProductForm):
class Meta(base_forms.ProductForm.Meta):
model = Product
fields = [
"title",
"upc",
"description",
# "video_url", # Uncomment this if you want to include video_url
"is_public",
"is_discountable",
"structure",
"slug",
"meta_title",
"meta_description",
]

damn formatting!

Aaron Jack

unread,
Nov 14, 2024, 12:55:39 PM11/14/24
to django-oscar
its dashboard/catalogue/forms.py 

Hugo

unread,
Nov 19, 2024, 3:13:32 AM11/19/24
to django-oscar

Maybe I don't put it in the correct place, but I don't see the new field. I only see them if I add it to ProductAttribute. But I need to create Signal handler to create the travel product class after migrations. And I don't know if its a good way to proceed.

Aaron Jack

unread,
Nov 19, 2024, 4:45:43 AM11/19/24
to django-oscar
post some code, lets see whats going on! :)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages