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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/zengqiu/django-ext",
"name": "django-ext",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "",
"author": "zengqiu",
"author_email": "zengqiu@qq.com",
"download_url": "https://files.pythonhosted.org/packages/4f/46/3552cf853ff869e4362803a11405cfdc97bd2e4700638e2c2cde9f0e8225/django-ext-0.9.tar.gz",
"platform": "any",
"description": "Django Ext\r\n==========\r\n\r\nSome extensions for Django.\r\n\r\n# Models\r\n\r\n## TimestampModel\r\n\r\nAdd `created_at` and `updated_at` for model.\r\n\r\n## TimeRangeModel\r\n\r\nAdd `started_at` and `ended_at` for model.\r\n\r\n## UserTrackModel\r\n\r\nAdd `created_by` and `update_by` for model.\r\n\r\nThis model requires `django-currentuser`, and should add it to the middleware classes in your settings.py:\r\n\r\n```\r\nMIDDLEWARE = (\r\n ...,\r\n 'django_currentuser.middleware.ThreadLocalUserMiddleware',\r\n)\r\n```\r\n\r\n## ExtraFieldsManager\r\n\r\n`ExtraFieldsManager` is intended to be used in conjunction with `ExtraFieldsQuerySet` to filter extra added fields using custom filter conditions.\r\n\r\nWhile initializing the `ExtraFieldsManager` class, it is necessary to use the `fields` parameter to specify extra fields and their corresponding filter conditions generation functions.\r\n\r\nUsage:\r\n\r\n```\r\nclass MyModel(models.Model):\r\n relation = models.ForeignKey(RelationModel, models.CASCADE, +, null=False)\r\n\r\n objects = ExtraFieldsManager(fields={\r\n # users: an extra field that is not present in the model\r\n # lambda function: used to generate complex query conditions\r\n 'users': lambda x: Q(relation__data__users__contained_by=[str(user.id) for user in x]) | \\\r\n Q(relation__data__groups__contained_by=Group.objects.filter(user__in=x).distinct().values_list('id', flat=True))\r\n })\r\n```\r\n\r\n# Commands\r\n\r\n## translate\r\n\r\nTranslate the permission names into the local language.\r\n\r\n```\r\n$ python manage.py translate\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Django Extensions",
"version": "0.9",
"project_urls": {
"Homepage": "https://github.com/zengqiu/django-ext"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2b607ec290e7af9474d8a32f321fb15bd09173cb90fd275e68a284ae98650e37",
"md5": "7101d0afef80d902dd2f1c51aa046fec",
"sha256": "8a3307d1ea667478bd30ea1b5b5809368160461cf218374b9614fb2fd4179176"
},
"downloads": -1,
"filename": "django_ext-0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7101d0afef80d902dd2f1c51aa046fec",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 6828,
"upload_time": "2024-01-05T03:40:00",
"upload_time_iso_8601": "2024-01-05T03:40:00.057789Z",
"url": "https://files.pythonhosted.org/packages/2b/60/7ec290e7af9474d8a32f321fb15bd09173cb90fd275e68a284ae98650e37/django_ext-0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4f463552cf853ff869e4362803a11405cfdc97bd2e4700638e2c2cde9f0e8225",
"md5": "a372afab17a5cbc057b98d0f9af19983",
"sha256": "22b777bb6887c3d703fc154bd0eee10dcc488132139bf2884bcd8ec6470583e4"
},
"downloads": -1,
"filename": "django-ext-0.9.tar.gz",
"has_sig": false,
"md5_digest": "a372afab17a5cbc057b98d0f9af19983",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 6703,
"upload_time": "2024-01-05T03:40:02",
"upload_time_iso_8601": "2024-01-05T03:40:02.603591Z",
"url": "https://files.pythonhosted.org/packages/4f/46/3552cf853ff869e4362803a11405cfdc97bd2e4700638e2c2cde9f0e8225/django-ext-0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-05 03:40:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zengqiu",
"github_project": "django-ext",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-ext"
}