Package contain necessary tools to complement your Django ORM usage
Project description
Django-DB-Helper
Package contain necessary tools to complement your Django ORM usage.
Install
$ pip install django-db-helper
Usage
Get Object or None
Model.objects.get() is widely use in getting a single record from the database. A DoesNotExist exception is thrown when the record is not found. get_object_or_none returns None when no matching record is found. This method is very helpful because most developers do not handle DoesNotExist exception from Model.objects.get() since it is used in anticipation that a single matching record is available.
from django_db_helper.get_object_or_none import get_object_or_none
#### Format
get_object_or_none(Model,key1=value1,key2=value2,..)
#### Getting User Object from User Model with an available username
user = get_object_or_none(User,username="andrewsxx")
//=> user object
#### Getting User Object from User Model with an available username
user = get_object_or_none(User,username="andrewsxx1234")
//=> None
License
MIT © [Andrews Agyemang Opoku]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_db_helper-0.0.1.tar.gz
(2.0 kB
view hashes)
Built Distribution
Close
Hashes for django_db_helper-0.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b9a4f67e65fac1e7d198e2f0530ed4dd6833661c8b2eac1f7c913dc0b4b8682 |
|
MD5 | db63f36ee3a500dfc0dd5a670a91bf9e |
|
BLAKE2b-256 | 0ae0516d8d65ce62cfd0df1a3ae1f2a074c4fd933b306310781710a547c06cba |