Documentation for python-stdnet's DEVELOPMENT version. Get the release docs here.

Double Underscore NotationΒΆ

Stdnet makes extensive use of the __ double-underscore notation in several parts of the API.

  • A Query with range and text lookups:

    >>> from stdnet import odm
    >>> models = odm.Router()
    >>> models.register(MyModel)
    >>> qs = odm.mymodel.filter(size__gt=40, description__contains='technology')
    
  • An Query on a Field of a related model. For example, in the Position model one can filter, exclude or sort, with respect the instrument ccy Field in this way:

    qs = models.position.filter(instrument__ccy='EUR')
    qs = models.position.exclude(instrument__ccy='EUR')
    qs = models.position.query().sort_by('instrument__ccy')
    
  • In conjunction with load_only query method when you need to load only a subset of a related model fields:

    qs = models.position.query().load_only('size', 'instrument__ccy')
    
  • In the StdModel.get_attr_value() method, for example:

    p.get_attr_value('instrument')
    # same as
    p.instrument
    

    and:

    p.get_attr_value('instrument__ccy')
    # same as
    p.instrument.ccy
    

Previous topic

Performance

Next topic

Export & Load data

This Page