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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a15c0a88f320572a88111c2c6aba25897dc01019f200c66988f1ae286490c699 |
|
MD5 | 7a54e1902694469dc8255dae6439a76f |
|
BLAKE2b-256 | 2f06e73b32b9460d4cb9d0cba194e8d0bb4042cf3803679968969a4dafaf3c53 |
Close
Hashes for django_lookup_property-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89a0caa8a328502917ffca18b42c8121ef714875a9a8e3a17d533b6680e3ab23 |
|
MD5 | 3dc7082ebac1a9222d05b4be231c9529 |
|
BLAKE2b-256 | 822c9808eb6e5c6df02d9afcde38e57ea51335c5da579e570daef5c8511da6b2 |