Skip to content

Add an ident_(pk) method to all models to quickly do a pk lookup in the form Model.ident_(pk)

License

Notifications You must be signed in to change notification settings

ckirby/django-model-ident

Repository files navigation

django-model-ident

https://badge.fury.io/py/django-model-ident.png https://travis-ci.org/ckirby/django-model-ident.png?branch=master https://coveralls.io/repos/ckirby/django-model-ident/badge.png?branch=master

django-model-ident provides a quick lookup for django models by pk only. Instead of writing ModelName.objects.get(pk=pk) write ModelName.ident_(pk)

Project

The project can be found at https://github.com/ckirby/django-model-ident

Requirements

  • Django 1.11+
  • Python 3.4+

Installation

pip install django-model-ident

Usage

Add 'model-ident' to your INSTALLED_APPS

How Does It Work

On ready() django-model-ident monkey patches all the models found in your INSTALLED_APPS with the method ident_(pk). This calls <model>._base_manager.get(pk=pk). We use _base_manager so as not to get confused by changes in ModelManagers.

About

Add an ident_(pk) method to all models to quickly do a pk lookup in the form Model.ident_(pk)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages