{"id":16802927,"url":"https://github.com/coady/django-model-values","last_synced_at":"2025-04-05T18:06:31.333Z","repository":{"id":2706886,"uuid":"42797445","full_name":"coady/django-model-values","owner":"coady","description":"Taking the O out of ORM.","archived":false,"fork":false,"pushed_at":"2025-01-16T22:45:20.000Z","size":1057,"stargazers_count":68,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-29T17:06:06.329Z","etag":null,"topics":["column-oriented","data-mapper","django","models","orm","pandas"],"latest_commit_sha":null,"homepage":"https://coady.github.io/django-model-values","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coady.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-20T02:34:12.000Z","updated_at":"2025-01-16T22:45:22.000Z","dependencies_parsed_at":"2023-07-06T07:28:08.088Z","dependency_job_id":"1d40efb4-451a-4e06-a4ca-e85b3129cd00","html_url":"https://github.com/coady/django-model-values","commit_stats":{"total_commits":153,"total_committers":3,"mean_commits":51.0,"dds":"0.12418300653594772","last_synced_commit":"6b96fab2d61e7ac4f27bd095cdcc426db89f3fbe"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fdjango-model-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fdjango-model-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fdjango-model-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fdjango-model-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coady","download_url":"https://codeload.github.com/coady/django-model-values/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378140,"owners_count":20929296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["column-oriented","data-mapper","django","models","orm","pandas"],"created_at":"2024-10-13T09:41:05.441Z","updated_at":"2025-04-05T18:06:31.314Z","avatar_url":"https://github.com/coady.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![image](https://img.shields.io/pypi/v/django-model-values.svg)](https://pypi.org/project/django-model-values/)\n![image](https://img.shields.io/pypi/pyversions/django-model-values.svg)\n![image](https://img.shields.io/pypi/djversions/django-model-values.svg)\n[![image](https://pepy.tech/badge/django-model-values)](https://pepy.tech/project/django-model-values)\n![image](https://img.shields.io/pypi/status/django-model-values.svg)\n[![build](https://github.com/coady/django-model-values/actions/workflows/build.yml/badge.svg)](https://github.com/coady/django-model-values/actions/workflows/build.yml)\n[![image](https://codecov.io/gh/coady/django-model-values/branch/main/graph/badge.svg)](https://codecov.io/gh/coady/django-model-values/)\n[![CodeQL](https://github.com/coady/django-model-values/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/coady/django-model-values/actions/workflows/github-code-scanning/codeql)\n[![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![image](https://mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\n[Django](https://docs.djangoproject.com) model utilities for encouraging direct data access instead of unnecessary object overhead. Implemented through compatible method and operator extensions to `QuerySets` and `Managers`.\n\nThe goal is to provide elegant syntactic support for best practices in using Django's ORM. Specifically avoiding the inefficiencies and race conditions associated with always using objects.\n\n## Usage\nTypical model usage is verbose, inefficient, and incorrect.\n\n```python\nbook = Book.objects.get(pk=pk)\nbook.rating = 5.0\nbook.save()\n```\n\nThe correct method is generally supported, but arguably less readable.\n\n```python\nBook.objects.filter(pk=pk).update(rating=5.0)\n```\n\n`model_values` encourages the better approach with operator support.\n\n```python\nBook.objects[pk]['rating'] = 5.0\n```\n\nSimilarly for queries:\n\n```python\n(book.rating for book in books)\nbooks.values_list('rating', flat=True)\nbooks['rating']\n```\n\nColumn-oriented syntax is common in panel data layers, and the greater expressiveness cascades. `QuerySets` also support aggregation and conditionals.\n\n```python\nbooks.values_list('rating', flat=True).filter(rating__gt=0)\nbooks['rating'] \u003e 0\n\nbooks.aggregate(models.Avg('rating'))['rating__avg']\nbooks['rating'].mean()\n```\n\n`Managers` provide a variety of efficient primary key based utilities. To enable, instantiate the `Manager` in your models. As with any custom `Manager`, it doesn't have to be named `objects`, but it is designed to be a 100% compatible replacement.\n\n```python\nfrom model_values import Manager\n\nclass Book(models.Model):\n    ...\n    objects = Manager()\n```\n\n`F` expressions are also enhanced, and can be used directly without model changes.\n\n```python\nfrom model_values import F\n\n.filter(rating__gt=0, last_modified__range=(start, end))\n.filter(F.rating \u003e 0, F.last_modified.range(start, end))\n```\n\n## Installation\n```console\n% pip install django-model-values\n```\n\n## Tests\n100% branch coverage.\n\n```console\n% pytest [--cov]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fdjango-model-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoady%2Fdjango-model-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fdjango-model-values/lists"}