Skip to main content

DjangoQL

https://travis-ci.org/ivelum/djangoql.svg?branch=master

Query mini-language that translates into Django ORM. Supports logical operators, parenthesis, table joins, works with any Django models. Tested vs. Python 2.7, 3.5 and 3.6, Django 1.8, 1.9, 1.10.

Installation

$ pip install djangoql

Usage

You can add DjangoQL search functionality to any Django model using DjangoQLQuerySet:

from django.db import models

from djangoql.queryset import DjangoQLQuerySet


class Book(models.Model):
    name = models.CharField(max_length=255)
    author = models.ForeignKey('auth.User')

    objects = DjangoQLQuerySet.as_manager()

With the example above you can perform search like this:

qs = Book.objects.djangoql(
    'name ~ "war" and author.last_name = "Tolstoy"'
)

It returns a normal queryset, so you can extend it and reuse if necessary. The following code works fine:

print(qs.count())

Alternatively you can add DjangoQL search to any existing queryset, even if it’s not an instance of DjangoQLQuerySet:

from django.contrib.auth.models import User

from djangoql.queryset import apply_search

qs = User.objects.all()
qs = apply_search(qs, 'groups = None')
print(qs.exists())

Django admin integration

Add DjangoQLSearchMixin to your model admin, and it will replace standard Django search functionality with DjangoQL search. Example:

from django.contrib import admin

from djangoql.admin import DjangoQLSearchMixin

from .models import Book


@admin.register(Book)
class BookAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
    pass

License

MIT

Metadata

Release files for djangoql 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangoql 0.1.1
File Size Uploaded Provenance Actions
djangoql-0.1.1.tar.gz 8.5 kB Without provenance Details for djangoql-0.1.1.tar.gz

Release files / djangoql-0.1.1.tar.gz

Download URL djangoql-0.1.1.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
83baf9bdbf1e0fcbe59241fed90e72b28f09705ae96d37ee5721b88ba0e023af
BLAKE2b-256 checksum
How to use checksums
56e54b4dd16bd20fd31c5c64c2f202509f7d404dacf0a32daf7bbb72e6f5eb07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for djangoql 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page