Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

abstract_models.py 863B

12345678910111213141516171819202122232425262728
  1. """
  2. Abstract models for product images
  3. """
  4. from django.db import models
  5. from django.utils.translation import ugettext as _
  6. class AbstractImage(models.Model):
  7. """
  8. An image of a product
  9. """
  10. product = models.ForeignKey('product.Item', related_name='images')
  11. # Namespacing path with app name to avoid clashes with other apps
  12. path_to_original = models.ImageField(upload_to='product-images/%Y/%m/')
  13. path_to_thumbnail = models.ImageField(upload_to='product-images/%Y/%m/')
  14. # Use display_order to determine which is the "primary" image
  15. display_order = models.PositiveIntegerField()
  16. date_created = models.DateTimeField(auto_now_add=True)
  17. def is_primary(self):
  18. return self.display_order == 0
  19. class Meta:
  20. abstract = True
  21. def __unicode__(self):
  22. return "Image of '%s'" % self.product