def get_or_create_calendar_for_object(self, obj, distinction='', name=None):
        """
        >>> user = User(username="jeremy")
        >>> user.save()
        >>> calendar = Calendar.objects.get_or_create_calendar_for_object(user, name = "Jeremy's Calendar")
        >>> calendar.name
        "Jeremy's Calendar"
        """
        try:
            return self.get_calendar_for_object(obj, distinction)
        except Calendar.DoesNotExist:
            if name is None:
                calendar = self.model(name=str(obj))
            else:
                calendar = self.model(name=name)
            calendar.slug = slugify(calendar.name)
            calendar.save()
            calendar.create_relation(obj, distinction)
            return calendar
def get_or_create_calendar_for_object ( self , obj , distinction = '' , name = None ) : try : return self . get_calendar_for_object ( obj , distinction ) except Calendar . DoesNotExist : if name is None : calendar = self . model ( name = str ( obj ) ) else : calendar = self . model ( name = name ) calendar . slug = slugify ( calendar . name ) calendar . save ( ) calendar . create_relation ( obj , distinction ) return calendar
>>> user = User(username="jeremy")
        >>> user.save()
        >>> calendar = Calendar.objects.get_or_create_calendar_for_object(user, name = "Jeremy's Calendar")
        >>> calendar.name
        "Jeremy's Calendar"