Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

managers.py 692B

12345678910111213141516171819202122232425262728
  1. from django.db import models
  2. class ProductManager(models.Manager):
  3. def base_queryset(self):
  4. """
  5. Return ``QuerySet`` with related content pre-loaded.
  6. """
  7. return self.get_query_set().select_related(
  8. 'product_class',
  9. ).prefetch_related(
  10. 'variants',
  11. 'product_options',
  12. 'product_class__options',
  13. 'stockrecords',
  14. 'images',
  15. ).all()
  16. class BrowsableProductManager(ProductManager):
  17. """
  18. Excludes non-canonical products
  19. """
  20. def get_query_set(self):
  21. return super(BrowsableProductManager, self).get_query_set().filter(
  22. parent=None)