Няма описание

models.py 1.1KB

1234567891011121314151617181920212223242526272829
  1. from django.db import models
  2. from smart_selects.db_fields import (
  3. ChainedForeignKey,
  4. ChainedManyToManyField,
  5. GroupedForeignKey,
  6. )
  7. from django.contrib.auth.models import User
  8. # Create your models here.
  9. from mptt.models import MPTTModel, TreeForeignKey
  10. from cms.models import PostCat, Post
  11. from fruit.models import Product, ProductType
  12. class GenericModel(models.Model):
  13. created_at = models.DateTimeField(auto_now_add=True, null=True)
  14. updated_at = models.DateTimeField(auto_now=True)
  15. created_by = models.ForeignKey(User, null=True, editable=False, related_name='%(class)s_created', on_delete=models.SET_NULL)
  16. modified_by = models.ForeignKey(User, null=True, editable=False, related_name='%(class)s_modified', on_delete=models.SET_NULL)
  17. class Meta:
  18. abstract = True
  19. class SearchData(GenericModel, models.Model):
  20. q = models.CharField(max_length=200, blank=True, default="")
  21. product_type = TreeForeignKey(ProductType, on_delete=models.SET_NULL, null=True, blank=True)
  22. content_cat = TreeForeignKey(PostCat, on_delete=models.SET_NULL, null=True, blank=True)