This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class ProductSerializer(serializers.ModelSerializer): | |
| images = ImageSerializer(many=True, read_only=False) | |
| user = AccountSerializer(read_only=True) | |
| category = CategorySerializer() | |
| variants = ProductVariantSerializer(many=True, source='color_variants') | |
| is_favorite = serializers.SerializerMethodField() | |
| class Meta: | |
| model = Product | |
| fields = ( | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from django import forms | |
| from django.conf import settings | |
| from django.templatetags.static import static | |
| from nested_inline.admin import NestedInline | |
| class BaseBriefNestedInline(NestedInline): | |
| @property | |
| def media(self): | |
| extra = "" if settings.DEBUG else ".min" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def get_file_from_base64(file, file_name=None): | |
| if not file: | |
| return None | |
| if isinstance(file, dict): | |
| return None | |
| if file.startswith("data:"): | |
| data_parse = re.sub(r"^data:.+base64,(.+)$", r"\1", file) | |
| else: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | server { | |
| listen 80; | |
| root /PATH/TO/PUBLIC_ROOT; | |
| server_name EXAMPLE.COM www.EXAMPLE.COM; | |
| index index.html; | |
| # Add 1 week expires header for static assets | |
| location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
| expires 60d; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | obj_content_type = ContentType.objects.get_for_model(self.model) | |
| tag_items = TaggedItem.objects.filter(content_type__app_label=obj_content_type.app_label) | |
| tag_items = tag_items.filter(content_type__model=obj_content_type.model) | |
| tag_ids = tag_items.values_list('tag_id', flat=True) | |
| tags = Tag.objects.filter(id__in=tag_ids) | |
| tags = tags.annotate(num_times=Count('taggit_taggeditem_items')) | |
| tags = tags.filter(num_times__gte=1) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def reset_expire_time(slot, now_utc, ripening_time_s): | |
| slot.OutletToSlot.expire_time = now_utc + datetime.timedelta(seconds=ripening_time_s) | |
| slot.OutletToSlot.save() | |
| @api_view(['GET']) | |
| @permission_classes([IsAuthenticated]) | |
| def collect_slot_by_id(request, pk): | |
| slot = Slot.objects.get(id=pk) | |
| user = request.user.profile | |
| if slot.owner_id != user_id: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class CategoryView(ListView): | |
| template_name = 'catalog/list.html' | |
| queryset = Product.objects.all() | |
| paginate_by = 9 | |
| category = ... | |
| def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> http.HttpResponse: | |
| slug = kwargs.get('slug') | |
| try: | |
| category = Category.objects.get(slug=slug) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import logging | |
| import sqlparse | |
| from django.db import connection | |
| from django.template.defaultfilters import floatformat | |
| logger = logging.getLogger('debug') | |
| db_logger = logging.getLogger('debug-db') | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class SellProductFilter(BaseProductFilter): | |
| brand = django_filters.ModelMultipleChoiceFilter( | |
| label=_('Бренд'), | |
| field_name='brand', | |
| queryset=SellBrand.objects.all(), | |
| widget=widgets.CheckboxSelectMultiple(attrs={ | |
| 'class': 'list-unstyled' | |
| }) | |
| ) | |
| condition = django_filters.ChoiceFilter( | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class CategoryListView(ListView): | |
| model = Song | |
| queryset = Song.objects.all() | |
| template_name = "category.html" | |
| def get_queryset(self): | |
| queryset = super().get_queryset() | |
| category_slug = self.kwargs.get('category_slug') | |
| if category_slug is not None: | 
NewerOlder