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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 509f134e7ed4cdc97bb03839961b944ab36aa2e5a71c675939733540e1225cb9 |
|
MD5 | 3b5f6b5a2b6264a0cdbca134f3499094 |
|
BLAKE2b-256 | b2fd622417618aab470b877f462b6f6538bca66899c0e0a6bf4f14c20b81eae4 |
Close
Hashes for django_lookup_property-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9f5254da6367988262a2875620d2e40ca17a9f9d1263284423028aecafcf8b8 |
|
MD5 | 7882ffda396f6d34a3e927d158bf6557 |
|
BLAKE2b-256 | 36016148910b1a5d089867e591a2718aa1510f52df2310939ca076bcf2f2dc23 |