(sender, **kwargs)
Add a Querymanager for each status item dynamically.
Add a Querymanager for each status item dynamically.
Add a Querymanager for each status item dynamically .
def add_status_query_managers(sender, **kwargs):
    """
    Add a Querymanager for each status item dynamically.

    """
    if not issubclass(sender, StatusModel):
        return

    default_manager = sender._meta.default_manager

    for value, display in getattr(sender, 'STATUS', ()):
        if _field_exists(sender, value):
            raise ImproperlyConfigured(
                "StatusModel: Model '%s' has a field named '%s' which "
                "conflicts with a status of the same name."
                % (sender.__name__, value)
            )
        sender.add_to_class(value, QueryManager(status=value))

    sender._meta.default_manager_name = default_manager.name
def add_status_query_managers ( sender , * * kwargs ) : if not issubclass ( sender , StatusModel ) : return default_manager = sender . _meta . default_manager for value , display in getattr ( sender , 'STATUS' , ( ) ) : if _field_exists ( sender , value ) : raise ImproperlyConfigured ( "StatusModel: Model '%s' has a field named '%s' which " "conflicts with a status of the same name." % ( sender . __name__ , value ) ) sender . add_to_class ( value , QueryManager ( status = value ) ) sender . _meta . default_manager_name = default_manager . name