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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51e2eddf25739f2855733e84b818217c87001d05193aa15ad87662c3387e8cb5 |
|
MD5 | d41c313065bc1807e4bdcfc4b1e473b8 |
|
BLAKE2b-256 | 3eea8a1274e98b7d1963c877e8e9c91982cd00878c4cff1ea2e3b877e47b2422 |
Close
Hashes for django_lookup_property-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e53ab2f4537bea58f4b5f4439f0767d58f980e8ee9053b9527f78c054e05bd94 |
|
MD5 | d45f6d65e63f526d5109d8dfea6a7fee |
|
BLAKE2b-256 | 0909796e950b36ded86cb6f0ae1120fae758311f076941ba512ce67aff9e8bfe |