[Django]-Editing models and extending database structure in Saleor

-1šŸ‘

The django way to create new models, (and SaleorĀ“s backend is django based) is:

  1. You should create a new app on your store backend (the django part of saleor) with:

    $ python manage.py startapp artist

  2. Create your Artist model, with all the fields you want such as email, etcā€¦ in the file: artist/models.py.
  3. Modify the Product model in the file product/models.py by importing the Artist models and adding a ForeignKey (for example) relationship to it.
  4. Register the new artist app in your settings.pyā€˜s ā€œINSTALLED_APPSā€.
  5. Run python manage.py makemigrationsā€¦ (Check they include your changes to models)
  6. Run python manage.py migrate.

That should be it. ā€˜less I`m forgeting something, in which case, please post back when you have moved forward with this.


Notes:

  • You may want to back up your DB first.
  • Also when applying these migrations, django will ask you for a placeholder value for products which where in your DB before Product had an Artist field.

References:

šŸ‘¤Aerials

Leave a comment