You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
805 B

# -*- coding: utf-8 -*-
from django.db.models.signals import pre_save, post_save
from models import Country
from django.dispatch import receiver
from django.conf import settings
from functions.form_check import translit_with_separator
@receiver(post_save)
def country_post_save_handler(sender, **kwargs):
"""
"""
obj = kwargs['instance']
if kwargs['created']:
if not obj.url:
obj.url = translit_with_separator(obj.name)
if not obj.title:
# len(10) is a hack for detect if settings.LANGUAGES is not configured it return all langs
if len(settings.LANGUAGES) in range(10):
for code, name in settings.LANGUAGES:
obj.translate(code)
obj.title = '111'
obj.save()