# _*_ coding: utf-8 _*_
# @Time     : 15:12
# @Author   : Amir
# @Site     : 
# @File     : signals.py
# @Software : PyCharm

from django.db.models.signals import post_save
from django.dispatch import receiver

from .models import Category, Article


@receiver(post_save, sender=Article)
def set_item_position(sender, instance=None, created=False, **kwargs):
    if created:
        count = Category.objects.get(name=instance.category.name).articles.all().count()
        instance.position = count


412d825c70440961a1b38b1b36b21c885ad6e066
<mask token>

<mask token>


@receiver(post_save, sender=Article)
def set_item_position(sender, instance=None, created=False, **kwargs):
    if created:
        count = Category.objects.get(name=instance.category.name).articles.all(
            ).count()
        instance.position = count

from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Category, Article


@receiver(post_save, sender=Article)
def set_item_position(sender, instance=None, created=False, **kwargs):
    if created:
        count = Category.objects.get(name=instance.category.name).articles.all(
            ).count()
        instance.position = count

# _*_ coding: utf-8 _*_
# @Time     : 15:12
# @Author   : Amir
# @Site     : 
# @File     : signals.py
# @Software : PyCharm

from django.db.models.signals import post_save
from django.dispatch import receiver

from .models import Category, Article


@receiver(post_save, sender=Article)
def set_item_position(sender, instance=None, created=False, **kwargs):
    if created:
        count = Category.objects.get(name=instance.category.name).articles.all().count()
        instance.position = count

