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
File details
Details for the file django_lookup_property-0.1.6.tar.gz
.
File metadata
- Download URL: django_lookup_property-0.1.6.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9636465db8ff0100a57359ab5127f56099d2e8bfd7ba7225932df19731ee546e |
|
MD5 | a393aee39d08d8d63db03280ea135ed8 |
|
BLAKE2b-256 | 2370f364d3e77fcd9e15656a8c33e3e871a1d753d183df8705fa5b99bd84310f |
File details
Details for the file django_lookup_property-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: django_lookup_property-0.1.6-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0034a2aab5c893db5be42ed434395e61f6b2b1d69dc69d3c333e54c5a25cee66 |
|
MD5 | b12b2033d0fb4d090c9bab62ae1f7df9 |
|
BLAKE2b-256 | df61531f8d1c2cdc5b8469dd9a2dd3980ee42b1b696dc53e1992b0e3558b4a0e |