معرفی شرکت ها


django-predicate-1.4.0


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

A predicate class constructed like Django Q objects, used to test whether a new or modified model would match a query
ویژگی مقدار
سیستم عامل -
نام فایل django-predicate-1.4.0
نام django-predicate
نسخه کتابخانه 1.4.0
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Preston Holmes
ایمیل نویسنده preston@ptone.com
آدرس صفحه اصلی http://github.com/ptone/django-predicate
آدرس اینترنتی https://pypi.org/project/django-predicate/
مجوز BSD
django-predicate ================ django-predicate provides a Q like object to facilitate the question: "would this model instance be part of a query" but without running the query or even saving the object. Quickstart ---------- Install django-predicate: .. code-block:: console pip install django-predicate Then use the ``P`` object just as you would ``Q`` objects: .. code-block:: python from predicate import P p = P(some_field__startswith="hello", age__gt=20) You can then call the ``eval`` method with a model instance to check whether it passes the conditions: .. code-block:: python model_instance = MyModel(some_field="hello there", age=21) other_model_instance = MyModel(some_field="hello there", age=10) p.eval(model_instance) >>> True p.eval(other_model_instance) >>> False or you can use Python's ``in`` operator. .. code-block:: python model_instance in p >>> True Even though a predicate is not a true container class - it can be used as (and was designed as being) a virtual "set" of objects that meets some condiiton. Like Q objects, P objects can be ``&``'ed and ``|``'ed together to form more complex logic groupings. In fact, P objects are actually a subclass of Q objects, so you can use them in queryset filter statements: .. code-block:: python qs = MyModel.objects.filter(p) P objects also support ``QuerySet``-like filtering operations that can be applied to an arbitrary iterable: ``P.get(iterable)``, ``P.filter(iterable)``, and ``P.exclude(iterable)``: .. code-block:: python model_instance = MyModel(some_field="hello there", age=21) other_model_instance = MyModel(some_field="hello there", age=10) p.filter([model_instance, other_model_instance]) == [model_instance] >>> True p.get([model_instance, other_model_instance]) == model_instance >>> True p.exclude([model_instance, other_model_instance]) == [other_model_instance] >>> True If you have a situation where you want to use querysets and predicates based on the same conditions, it is far better to start with the predicate. Because of the way querysets assume a SQL context, it is non-trivial to reverse engineer them back into a predicate. However as seen above, it is very straightforward to create a queryset based on a predicate.


نحوه نصب


نصب پکیج whl django-predicate-1.4.0:

    pip install django-predicate-1.4.0.whl


نصب پکیج tar.gz django-predicate-1.4.0:

    pip install django-predicate-1.4.0.tar.gz