Skip to main content

A django app to store and load partial queries from external sources

Project description

django-query-parser

A django app to parse queries written outside the django app.

Idea

Some queries are controls the business case, so it will be benefical if they are can saved outside the application like in a config file or a database so the logic can be changed without changing the code.

Samples

  1. to write an 'or'
     {"or":{"status_id" : 3, "name__icontains":"Ahmed"}}
    
  2. to write negation
    {"or":{"status_id" : 3, "~name__icontains":"Ahmed"}}
    
  3. to write an 'and'
     {"and":{"status_id" : 3, "name__icontains":"Ahmed"}}
    
    or
    {"status_id" : 3, "name__icontains":"Ahmed"}
    

Installation

pip install django-query-parser

Example

from test_app

from query_parser.Parser import  Parse
d = {"or": {
   "status": "Completed",
   "ordered_by_id": 2
   }}
res = Parse(d)
print(Order.objects.filter(res).count())

Operation Supported

  1. AND
  2. OR
  3. NOT: with a '~' in field name example
    d = {"status": "Completed", "~ordered_by_id": 1}
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-query-parser-0.0.3.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file django-query-parser-0.0.3.tar.gz.

File metadata

  • Download URL: django-query-parser-0.0.3.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.17

File hashes

Hashes for django-query-parser-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2a7f32aa83999e9e1f6ab796715de69517dc5d0a7acf93eba81dfac15ba1d540
MD5 dcf69b3f1bb843d339b2590197f73b43
BLAKE2b-256 32e3625d1c5ad47386183bbd1ab1f87d78fa970b1038f4d6d764fa293aef79ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page