5

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.

Ryan R. Rosario
  • 5,114
  • 9
  • 41
  • 56
Alex Nechaev
  • 181
  • 1
  • 2
  • 8

4 Answers4

6

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

D2TheC
  • 2,203
  • 20
  • 23
2

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

Art
  • 23,747
  • 29
  • 89
  • 101
  • I guess this answer is irrelevant here as user has only asked 'How to add product from the dashboard', not pro-grammatically. – Jay Modi Jun 03 '17 at 05:52
1

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.

Hayden Crocker
  • 509
  • 4
  • 15
-1

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

Sandeep Balagopal
  • 1,943
  • 18
  • 28