Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Function that assigns object column defaults on object initialization
time. By default calling this function applies instant defaults to all
your models.

Setting up instant defaults::


    from sqlalchemy_utils import force_instant_defaults

(more...)

        def force_instant_defaults(mapper=None):
    """
    Function that assigns object column defaults on object initialization
    time. By default calling this function applies instant defaults to all
    your models.

    Setting up instant defaults::


        from sqlalchemy_utils import force_instant_defaults


        force_instant_defaults()

    Example usage::


        class Document(Base):
            __tablename__ = 'document'
            id = sa.Column(sa.Integer, autoincrement=True)
            name = sa.Column(sa.Unicode(50))
            created_at = sa.Column(sa.DateTime, default=datetime.now)


        document = Document()
        document.created_at  # datetime object


    :param mapper: The mapper which the automatic instant defaults forcing
                   should be applied to
    """
    if mapper is None:
        mapper = sa.orm.mapper
    sa.event.listen(mapper, 'init', instant_defaults_listener)
        


src/s/q/SQLAlchemy-Utils-0.25.4/sqlalchemy_utils/__init__.py   SQLAlchemy-Utils(Download)
    table_name,
)
from .listeners import (
    coercion_listener,
    force_auto_coercion,

src/s/q/sqlalchemy-utils-HEAD/sqlalchemy_utils/__init__.py   sqlalchemy-utils(Download)
    table_name,
)
from .listeners import (
    coercion_listener,
    force_auto_coercion,