コード例 #1
0
ファイル: signals.py プロジェクト: MasterBDX/school
def get_publish_date(sender, instance, *args, **kwargs):
    if instance.active and not instance.published_date:
        instance.published_date = timezone.now()
    if not instance.active and instance.published_date:
        instance.published_date = None

    if not instance.slug:
        instance.slug = unique_slug_generator(instance)
コード例 #2
0
def pre_save_action(sender, instance, *args, **kwargs):
    content = instance.content
    if len(content) <= 40:
        slug = content
    else:
        slug = content[:40]
    if not instance.slug:
        instance.slug = unique_slug_generator(instance, new_slug=slugify(slug))
コード例 #3
0
ファイル: models.py プロジェクト: ZigZag-CS/eant_src
def tag_pre_save_receiver(sender, instance, *args, **kwargs):
    if not instance.slug:
        instance.slug = unique_slug_generator(instance)
コード例 #4
0
def product_presave_reciever(sender, instance, *args, **kwargs):
    # if not already created -> create it
    if not instance.slug:
        # generate a unique slug name
        instance.slug = unique_slug_generator(instance)
コード例 #5
0
def product_pre_save_reciever(sender, instance, *args, **kwargs):
    if not instance.slug:
        instance.slug = unique_slug_generator(instance)