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.13.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 487e2a12a52c07c6f8e7fcc9bc19f4d91ba866f8d8ee0a04476cbbe09a4fe243 |
|
MD5 | 5d83526e5c9213047b4fc2210b6fcd28 |
|
BLAKE2b-256 | d41dbc029aa3a7e593c7438eb326bb0bdde16f624410d6009c5b44bd95eba41c |
Close
Hashes for django_lookup_property-0.0.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8829ef33e2f5b78a53088b15e7c18ef18b7236a68407efe50aae803f9a8de726 |
|
MD5 | 9a84d51ce2533e6454a56ba02720cbd2 |
|
BLAKE2b-256 | f477ca0c0524d28d84a7fd07762a924fce0abb2a299fd66133aa81a914b329c9 |