Skip to main content

CLI tool to analyze Django ORM filter, exclude, and annotate usage on a specific model.

Project description

README.md

record-query-analysis

record-query-analysis is a command-line tool for analyzing Django ORM usage of .filter(), .exclude(), and .annotate() on a specific model across a Python codebase.

🔍 Features

  • Detects chained querysets on a target model (e.g., Record.objects.filter(...).annotate(...))
  • Extracts used fields in filter, exclude, and annotate
  • Aggregates and counts unique field combinations
  • Outputs results in table, JSON, or CSV formats

🚀 Installation

pip install -e .  # or build via uv, poetry, etc.

🧪 Usage

record-query-analysis path/to/your/codebase --model=Record --output-format=table

Options:

  • --model: Django model name (default: Record)
  • --output-format: table (default), json, or csv
  • --csv-file: custom file path for CSV output

📦 Example Output

Filter/Exclude Fields                  | Annotate Fields           | Frequency | Locations
-----------------------------------------------------------------------------------------------
is_active, location_id                | client                    |        12 |
                                                                ↳ app/views/reports.py:45

📄 License

MIT License

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_index_analyzer-0.1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_query_index_analyzer-0.1.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file django_query_index_analyzer-0.1.4.tar.gz.

File metadata

File hashes

Hashes for django_query_index_analyzer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a739d0f1196be020e118bb720d38ae4e8840d72d1259a24592124816d61ac844
MD5 03b5d000115eeca177dc2d840ebe604d
BLAKE2b-256 3265ee8f699e1cb7ee0a38089022fd0722b03780583b2aae576a83e273b572df

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_query_index_analyzer-0.1.4.tar.gz:

Publisher: ci.yml on eliziario/django_query_analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_query_index_analyzer-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_query_index_analyzer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 19ed4b249b3e5845323b5945fff7e522e77ccba60ce0893002807cff0a4b4178
MD5 08449a1f05c9bd98e036f572beafbf14
BLAKE2b-256 3ad4adb576359ac6ac58b4a0ff358b5f9e70a24128a13418343f9b057c057d8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_query_index_analyzer-0.1.4-py3-none-any.whl:

Publisher: ci.yml on eliziario/django_query_analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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