Alex Nechaev
Alex Nechaev

Reputation: 181

Django Oscar. How to add product?

I'm a beginner in Python and Django. I have installed django-oscar. Then I Configured it and started the server, it works.

Now, I don't understand how to add a product?

At the dashboard there is a button Create new product. But in order to add new product it asks to select product class and I can not find any product class in the given dropdown options.

Provide me a demo example of how to add product in django-oscar.

Upvotes: 5

Views: 6787

Answers (4)

D2TheC
D2TheC

Reputation: 2369

You need to be logged in as a superuser and go to the store/dashboard URL DO NOT ADMINISTER THIS FROM THE NORMAL DJANGO ADMIN CONSOLE (even though that answer was accepted?)

Here is an example of what this looks like in the included sandbox app enter image description here

You need to add a category, product type, and partner and only then can you begin adding real products

Upvotes: 6

Hayden Crocker
Hayden Crocker

Reputation: 519

There is a separate page to administer product types, complete with a "Create new product type" button.

Using django-admin is not a good solution, you may be able to add product types and products through it, but you'll be missing out on any dashboard hooks into the normal process.

A look at the source code shows that whilst you may be able to add a product without a type (the FK is nullable), you may then experience other problems down the line as oscar expects only child products to have a null product_class.

    #: None for child products, they inherit their parent's product class
    product_class = models.ForeignKey(
        'catalogue.ProductClass', null=True, on_delete=models.PROTECT,
        verbose_name=_('Product Type'), related_name="products",
        help_text=_("Choose what type of product this is"))

Definitely best to try to work with the system rather than around.

Upvotes: 1

Sandeep Balagopal
Sandeep Balagopal

Reputation: 1983

You have to add atleast one product class /admin/catalogue/productclass/

Upvotes: -1

Art
Art

Reputation: 24597

Check out this commit - it hasn't been merged to the Oscar's master yet, but should give you an idea on how you can create products programmatically, for instance when importing data.

https://github.com/ArtS/django-oscar/blob/3f9abaf8d5c179c385b90dfa463a35ff9f92f73c/docs/source/recipes/importing_a_catalogue.rst

Upvotes: 2

Related Questions