def project_post_save(sender, instance, created, **kwargs):
 if (not created):
  return
 if instance._importing:
  return
 template = getattr(instance, 'creation_template', None)
 if (template is None):
  ProjectTemplate = apps.get_model('projects', 'ProjectTemplate')
  template = ProjectTemplate.objects.get(slug=settings.DEFAULT_PROJECT_TEMPLATE)
 if instance.tags:
  template.tags = instance.tags
 if instance.tags_colors:
  template.tags_colors = instance.tags_colors
 template.apply_to_project(instance)
 instance.save()
 Role = apps.get_model('users', 'Role')
 try:
  owner_role = instance.roles.get(slug=template.default_owner_role)
 except Role.DoesNotExist:
  owner_role = instance.roles.first()
 if owner_role:
  Membership = apps.get_model('projects', 'Membership')
  Membership.objects.create(user=instance.owner, project=instance, role=owner_role, is_admin=True, email=instance.owner.email)

def project_post_save ( sender , instance , created , ** kwargs ) : if ( not created ) : return if instance . _importing : return template = getattr ( instance , 'creation_template' , None ) if ( template is None ) : ProjectTemplate = apps . get_model ( 'projects' , 'ProjectTemplate' ) template = ProjectTemplate . objects . get ( slug = settings . DEFAULT_PROJECT_TEMPLATE ) if instance . tags : template . tags = instance . tags if instance . tags_colors : template . tags_colors = instance . tags_colors template . apply_to_project ( instance ) instance . save ( ) Role = apps . get_model ( 'users' , 'Role' ) try : owner_role = instance . roles . get ( slug = template . default_owner_role ) except Role . DoesNotExist : owner_role = instance . roles . first ( ) if owner_role : Membership = apps . get_model ( 'projects' , 'Membership' ) Membership . objects . create ( user = instance . owner , project = instance , role = owner_role , is_admin = True , email = instance . owner . email )
populate new project dependen default data .