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 Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
@lookup_property
def full_name(self):
return Concat("first_name", Value(" "), "last_name")
# -------------------------------------------------------------
>>> Person.objects.create(first_name="John", last_name="Doe")
>>> person = Person.objects.filter(full_name="John Doe").first()
>>> person.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.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 945154168f7f173abffdea19a3c029bab5ba439c47f1db7d97e759be493b9e7a |
|
MD5 | 9d5c64a7a691cff9b9468d6011cdce6f |
|
BLAKE2b-256 | 3171ce3cd2c019158ab3f1a1bc75b82c79325113b8af9a1b69392cda8abdc377 |
Close
Hashes for django_lookup_property-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1343cede39ce1200de2f2b10918288061d0580c2170d455ec8d87446fc860885 |
|
MD5 | 6d2667cb9d0892d2d0b35c594021c76e |
|
BLAKE2b-256 | dc67a92b80a5ecd2bba98be6ac4c610e3a30af63641b1c0331db300982335cef |