{"id":16337972,"url":"https://github.com/jnoortheen/django-utils-plus","last_synced_at":"2025-07-27T03:05:56.713Z","repository":{"id":22362569,"uuid":"96034872","full_name":"jnoortheen/django-utils-plus","owner":"jnoortheen","description":"Reusable Django app with various mixins and utility functions.","archived":false,"fork":false,"pushed_at":"2025-06-16T14:26:15.000Z","size":282,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T14:59:25.572Z","etag":null,"topics":["django","django-models","django-routing","django-urls","django-utilities","middleware","mixins","readable-urls","routing","urlpatterns","urls"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jnoortheen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-07-02T16:15:38.000Z","updated_at":"2025-06-16T14:25:08.000Z","dependencies_parsed_at":"2023-01-11T21:35:30.869Z","dependency_job_id":"4cc1dd2a-7b96-4822-9139-9dea8113b649","html_url":"https://github.com/jnoortheen/django-utils-plus","commit_stats":{"total_commits":142,"total_committers":2,"mean_commits":71.0,"dds":0.06338028169014087,"last_synced_commit":"795f9fe48b658db7e700fafe67aa28fc55bc79c6"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/jnoortheen/django-utils-plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Fdjango-utils-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Fdjango-utils-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Fdjango-utils-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Fdjango-utils-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jnoortheen","download_url":"https://codeload.github.com/jnoortheen/django-utils-plus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Fdjango-utils-plus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265866271,"owners_count":23840938,"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":["django","django-models","django-routing","django-urls","django-utilities","middleware","mixins","readable-urls","routing","urlpatterns","urls"],"created_at":"2024-10-10T23:48:42.800Z","updated_at":"2025-07-27T03:05:56.704Z","avatar_url":"https://github.com/jnoortheen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# utils-plus \nA simple reusable Django app with various mixins and utility functions.\n\n-------\n\n[![PyPi Version](https://img.shields.io/pypi/v/pconf.svg?style=flat)](https://pypi.python.org/pypi/pconf)\n[![Python Version](https://img.shields.io/pypi/pyversions/returns.svg)](https://pypi.org/project/returns/)\n\n-------\n\n# Installation\ninstall the package using the below command\n\n```commandline\npip install django-utils-plus\n```\n\nor install the development version using \n```commandline\npip install git://github.com/jnoortheen/django-utils-plus.git@master#egg=django-utils-plus\n```\n\n# Utils\n\n## Management Commands\n - clear_records\n - create_admin\n - test_mail\n - cleardata\n - create_middleware\n    \n## Template tags\n 1. klass\n 1. [unpkg](#unpkg)\n 1. [jsdelivr](#jsdelivr) (combined support as well)\n \n### serve static files using npm\n it is convenient to keep track of all external `js` libraries in project using \n a `package.json`. It is used to keep latest version of available packages. \n The following template tags can be used to serve these packages right from CDN on production and \n `node_modules` during development\n\n#### unpkg\n Alternative to standard `static` template tag. When you are using external static files/libraries\nlike bootstrap, jquery you may want to load them from CDNs instead of managing them yourself in production.\nThis tag helps you to do that. When `settings.DEBUG` is false, this will return paths that resolved from\n`package.json` to versioned `unpkg.com`. Otherwise it will resolve to `node_modules` locally.\n\n#### jsdelivr\n    like `unpkg` adds support for using https://www.jsdelivr.com/\n\n#### Usage:\n\nload the template tags and use `unpkg` like `static` tag,\n\n```\n{% load static utils_plus_tags %}\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"{% unpkg 'bootstrap/dist/css/bootstrap.min.css' %}\"/\u003e\n\u003cscript src=\"{% unpkg 'bootstrap/dist/js/bootstrap.min.js' %}\"\u003e\u003c/script\u003e\n\u003cscript src=\"{% unpkg 'jquery/dist/jquery.min.js' %}\"\u003e\u003c/script\u003e\n```\n#### Note:\n1. the package.json should be present in the project ROOT DIR.\n1. When DEBUG is True the packages must  be installed and should be available already inside `node_modules`.\n \n\n## Middleware\n - login_required_middleware\n\n## Urls \u0026 Routing with ease\n\nAn elegant and DRY way to define urlpatterns. It has easier to nest many levels deeper and still have the readability.\nIt is just a wrapper behind the standard url(), include() methods.\n\nThis is how your urls.py may look\n```python\n### urls.py ###\nurlpatterns = [\n    url(r'^studenteditordocument/(?P\u003cdoc_pk\u003e\\d+)/edit/$', EditView.as_view(), name='edit-student-doc'),\n    url(r'^studenteditordocument/(?P\u003cdoc_pk\u003e\\d+)/export/$', ExportView.as_view(), name='export-editore-doc'),\n\n    url(r'^docs/$', Docs.as_view(), name='student-documents'),\n    url(r'^publish/$', PulishOrDelete.as_view(), {'action': 'publish'}, name=\"publish_document\"),\n    url(r'^delete/$', PulishOrDelete.as_view(), name='delete_document'),\n]\n```\n\nafter using `Url`\n```python\n### urls.py ###\n\nfrom utils_plus.router import url\n\nurlpatterns = list(\n        url('editor')[\n            url.int('doc_pk')[\n                url('edit', DocEditorView.as_view(), 'edit-doc'),\n                url('export', DocExporterView.as_view(), 'export-doc'),\n            ]\n        ]\n        + url('docs', Docs.as_view(), 'student-documents')\n        + url('publish', DeleteOrPublistDocument.as_view(), 'publish_document', action='publish')\n        + url('delete', DeleteOrPublistDocument.as_view(), 'delete_document')\n```\n\nsee `tests/test_router.py` for more use cases\n\n## Model \n\n1. `CheckDeletableModelMixin`\nadds a `is_deletable` method which then can be used to check any affected related records before actually deleting them.\noriginally it is copied from this [gist](https://gist.github.com/freewayz/69d1b8bcb3c225bea57bd70ee1e765f8)\n\n2. `ChoicesEnum`\nEnumerator class for use with the django ORM choices field\n\n3. `QueryManager`\nA DRYer way to set select_related, prefetch_related \u0026 filters to queryset.\n    - this has `first_or_create` method similar to get_or_create\n\n```python\nfrom django.db import models\nfrom utils_plus.models import QueryManager\n\nclass Post(models.Model):\n    author = models.ForeignKey('Author')\n    comments = models.ManyToManyField('Comment')\n    published = models.BooleanField()\n    pub_date = models.DateField()\n    \n    # custom managers\n    objects = QueryManager() # equivalent to models.Manager\n    public_posts = QueryManager(published=True).order_by('-pub_date')\n    rel_objects = QueryManager().selects('author').prefetches('comments')\n```\n\n## Config Option\n\n1. `URL_GROUP_TRAIL_SLASH`\n    - By default all the urls generated by this class will have trailing slash\n    - Set this to False in settings.py to change this behaviour\n\n## Views\n1. **CreateUpdateView**:\n    - combines CreateView and UpdateView\n\n# Testing the project\n    - clone the repo and run migrations after installing dependencies\n    - `inv test` will run all the test for the app\n\n# Development\n\n## Install dependencies\n\n```commandline\nuv sync\nmake lint test\n```\n\n## Release\n\nTo publish a new release:\n1. Create a new release on GitHub and tag it with a version number (e.g., v0.7.5)\n2. The workflow will automatically run tests, linting, and publish to PyPI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnoortheen%2Fdjango-utils-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnoortheen%2Fdjango-utils-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnoortheen%2Fdjango-utils-plus/lists"}