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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90e33b74d5cb25f04f7549904299cc22d0c906f5453e79d353df1395cc6f5cde |
|
MD5 | 328ab00276dd97cdd8d2a1ffb3ec8d67 |
|
BLAKE2b-256 | 534122c4df2e4b4693498d2f38ee4378627338a6acd79473426f564ff12bf888 |
Close
Hashes for django_lookup_property-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd021e999bdbcc70fcf1f102c379e613dd5dc583de70f0ca5e999352963a47db |
|
MD5 | 5f06d161510b928ad6dcdf447db3495d |
|
BLAKE2b-256 | d337c33dfde31b7c475bd954e22bb00eca6aea7871cbcf6d837eb442a6e11bf1 |