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.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb9f06116e2b2ab825d3a5f4a8d2772d801a18caedcb47735018da2c57a647af |
|
MD5 | 8cb6ae9e764a3813a37deda4f3466c7c |
|
BLAKE2b-256 | 0a65446f9e920ad59e8c8732cf441bff48068182cc84a82939b5cc6a7f34d6fa |
Close
Hashes for django_lookup_property-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef006438e5bff2c879dca74fef6d48c4fa5f60738aca4e24654a85dcbbbd5ddd |
|
MD5 | bb316101f64098253333a6092aff91bf |
|
BLAKE2b-256 | 373c138ed23781f1a3a5e95f354197b7274ca4f25891b517d1f20c787a465050 |