Django Extensions
Project description
Django Ext
Some extensions for Django.
Models
TimestampModel
Add created_at
and updated_at
for model.
TimeRangeModel
Add started_at
and ended_at
for model.
UserTrackModel
Add created_by
and update_by
for model.
This model requires django-currentuser
, and should add it to the middleware classes in your settings.py:
MIDDLEWARE = (
...,
'django_currentuser.middleware.ThreadLocalUserMiddleware',
)
ExtraFieldsManager
ExtraFieldsManager
is intended to be used in conjunction with ExtraFieldsQuerySet
to filter extra added fields using custom filter conditions.
While initializing the ExtraFieldsManager
class, it is necessary to use the fields
parameter to specify extra fields and their corresponding filter conditions generation functions.
Usage:
class MyModel(models.Model):
relation = models.ForeignKey(RelationModel, models.CASCADE, +, null=False)
objects = ExtraFieldsManager(fields={
# users: an extra field that is not present in the model
# lambda function: used to generate complex query conditions
'users': lambda x: Q(relation__data__users__contained_by=[str(user.id) for user in x]) | \
Q(relation__data__groups__contained_by=Group.objects.filter(user__in=x).distinct().values_list('id', flat=True))
})
Commands
translate
Translate the permission names into the local language.
$ python manage.py translate
Project details
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-ext-0.9.tar.gz
.
File metadata
- Download URL: django-ext-0.9.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22b777bb6887c3d703fc154bd0eee10dcc488132139bf2884bcd8ec6470583e4 |
|
MD5 | a372afab17a5cbc057b98d0f9af19983 |
|
BLAKE2b-256 | 4f463552cf853ff869e4362803a11405cfdc97bd2e4700638e2c2cde9f0e8225 |
File details
Details for the file django_ext-0.9-py3-none-any.whl
.
File metadata
- Download URL: django_ext-0.9-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a3307d1ea667478bd30ea1b5b5809368160461cf218374b9614fb2fd4179176 |
|
MD5 | 7101d0afef80d902dd2f1c51aa046fec |
|
BLAKE2b-256 | 2b607ec290e7af9474d8a32f321fb15bd09173cb90fd275e68a284ae98650e37 |