Django model properties that are also lookup expressions.
Project description
Django Lookup Property
pip install django-lookup-property
Documentation: https://mrthearman.github.io/django-lookup-property/
Source Code: https://github.com/MrThearMan/django-lookup-property/
Contributing: https://github.com/MrThearMan/django-lookup-property/blob/main/CONTRIBUTING.md
Django model properties that are also lookup expressions.
from lookup_property import lookup_property
from django.db import models
from django.db.models import Value
from django.db.models.functions import Concat
class Student(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
@lookup_property
def full_name():
return Concat("first_name", Value(" "), "last_name")
>>> from myapp.models import Student
>>> from lookup_property import L
>>>
>>> Student.objects.create(first_name="John", last_name="Doe")
>>> student = Student.objects.filter(L(full_name="John Doe")).first()
>>>
>>> student.full_name
'John Doe'
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
Built Distribution
Close
Hashes for django_lookup_property-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e4ba2725bc4566974fd7e58622103d2e64c0ba6f6f9b9a687661f418bb4d9a2 |
|
MD5 | c6cfc7d0235c9c4cc7ab1667dd6b11cf |
|
BLAKE2b-256 | 6ebbb09542cfbd2d534d88beb1fc03334d453f708fd22c0cf54c450b5c164885 |
Close
Hashes for django_lookup_property-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40b2c4fa92f69f6b4af2239cae9765f821eefb17cb31fad66ea39d86225fb296 |
|
MD5 | eacbe274f7c3048963a12efee218153e |
|
BLAKE2b-256 | 595fe709cdcdb0b6fb5c02dd924734ce1449efb06cf081dcaed1c16d3bdf47b5 |