django-async-orm


Namedjango-async-orm JSON
Version 0.1.12 PyPI version JSON
download
home_pagehttps://github.com/rednaks/django-async-orm
SummaryBringing async capabilities to django ORM
upload_time2023-05-11 18:18:23
maintainer
docs_urlNone
authorSkanderBM
requires_python>=3.7,<4.0
licenseMIT
keywords django async orm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Downloads](https://static.pepy.tech/badge/django-async-orm)](https://pepy.tech/project/django-async-orm)

## Disclaimer: Don't use this module in production it's still in active development.

# Django Async Orm
Django module that brings async to django ORM.

# Installing
```
python -m pip install django-async-orm
``` 

then add `django_async_orm` to your `INSTALLED_APPS` list:

```python
INSTALLED_APPS = [
    ...,
    'django_async_orm'
]
```
# Usage

Django Async Orm will patch all your existing models to add `async_*` prefixed methods.
To be

example:

```python
class MyModel(models.Model):
    name = models.CharField(max_length=250)

```

you can use it as follow:

```python
async def get_model():
    return await  MyModel.objects.async_get(name="something")
```

you can also iterate over a query set with `async for`:

```python
async def all_models():
    all_result_set = await MyModel.objects.async_all()
    async for obj in all_result_set:
        print(obj)
```

Some wrappers are also available for template rendering, form validation and login/logout


#### Async login
```python
from django_async_orm.wrappers import async_login

async def my_async_view(request):
    await async_login(request)
    ...
```

#### Form validation
```python

from django_async_orm.wrappers import async_form_is_valid
async def a_view(request):
    form = MyForm(request.POST)
    is_valid_form = await async_form_is_valid(form)
    if is_valid_form:
        ...
    
```


# Django ORM support:

This is an on going projects, not all model methods are ported.

### Manager:

| methods                                  | supported  | comments |
|------------------------------------------|------------|----------|
| `Model.objects.async_get`                | ✅ |  |
| `Model.objects.async_create`             | ✅ |  |
| `Model.objects.async_count`              | ✅ |  |
| `Model.objects.async_none`               | ✅ |  |
| `Model.objects.async_bulk_create`        | ✅ |  |
| `Model.objects.async_bulk_update`        | ✅ |  |
| `Model.objects.async_get_or_create`      | ✅ |  |
| `Model.objects.async_update_or_create`   | ✅ |  |
| `Model.objects.async_earliest`           | ✅ |  |
| `Model.objects.async_latest`             | ✅ |  |
| `Model.objects.async_first`              | ✅ |  |
| `Model.objects.async_last`               | ✅ |  |
| `Model.objects.async_in_bulk`            | ✅ |  |
| `Model.objects.async_delete`             | ✅ |  |
| `Model.objects.async_update`             | ✅ |  |
| `Model.objects.async_exists`             | ✅ |  |
| `Model.objects.async_explain`            | ✅ |  |
| `Model.objects.async_raw`                | ✅ |  |
| `Model.objects.async_all`                | ✅ |  |
| `Model.objects.async_filter`             | ✅ |  |
| `Model.objects.async_exclude`            | ✅ |  |
| `Model.objects.async_complex_filter`     | ✅ |  |
| `Model.objects.async_union`              | ✅ |  |
| `Model.objects.async_intersection`       | ✅ |  |
| `Model.objects.async_difference`         | ✅ |  |
| `Model.objects.async_select_for_update`  | ✅ |  |
| `Model.objects.async_prefetch_related`   | ✅ |  |
| `Model.objects.async_annotate`           | ✅ |  |
| `Model.objects.async_order_by`           | ✅ |  |
| `Model.objects.async_distinct`           | ✅ |  |
| `Model.objects.async_difference`         | ✅ |  |
| `Model.objects.async_extra`              | ✅ |  |
| `Model.objects.async_reverse`            | ✅ |  |
| `Model.objects.async_defer`              | ✅ |  |
| `Model.objects.async_only`               | ✅ |  |
| `Model.objects.async_using`              | ✅ |  |
| `Model.objects.async_resolve_expression` | ✅ |  |
| `Model.objects.async_ordered`            | ✅ |  |
| `__aiter__`                              | ✅ |  |
| `__repr__`                               | ✅ |  |
| `__len__`                                | ✅ |  |
| `__getitem__`                            | ✅ |  |
| `Model.objects.async_iterator`           | ❌ |  |

### RawQuerySet
Not supported ❌

You can still call `Model.object.async_raw()` but you will be unable to access the results.

### Model:

| methods                    | supported  | comments |
|----------------------------|------------|----------|
| `Model.async_save`                      | ❌ |  |
| `Model.async_update`                    | ❌ |  |
| `Model.async_delete`                    | ❌ |  |
| `...`                                   | ❌ |  |


### User Model / Manager
| methods                    | supported  | comments |
|----------------------------|------------|----------|
| `UserModel.is_authenticated`            | ✅ |  |
| `UserModel.is_super_user`               | ✅ |  |
| `UserModel.objects.async_create_user`   | ❌ |  |
| `...`                                   | ❌ |  |


### Foreign object lazy loading:
Not supported ❌


### Wrappers:
| methods                    | supported  | comments |
|----------------------------|------------|----------|
| `wrappers.async_render`            | ✅  |  |
| `wrappers.async_login`            | ✅  |  |
| `wrappers.async_logout`            | ✅  |  |




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rednaks/django-async-orm",
    "name": "django-async-orm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "django,async,orm",
    "author": "SkanderBM",
    "author_email": "skander.bmahmoud@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/04/61/758735273595625c143a02f67fea4e33bd0500894fe5b0c2835de9fb2b93/django-async-orm-0.1.12.tar.gz",
    "platform": null,
    "description": "[![Downloads](https://static.pepy.tech/badge/django-async-orm)](https://pepy.tech/project/django-async-orm)\n\n## Disclaimer: Don't use this module in production it's still in active development.\n\n# Django Async Orm\nDjango module that brings async to django ORM.\n\n# Installing\n```\npython -m pip install django-async-orm\n``` \n\nthen add `django_async_orm` to your `INSTALLED_APPS` list:\n\n```python\nINSTALLED_APPS = [\n    ...,\n    'django_async_orm'\n]\n```\n# Usage\n\nDjango Async Orm will patch all your existing models to add `async_*` prefixed methods.\nTo be\n\nexample:\n\n```python\nclass MyModel(models.Model):\n    name = models.CharField(max_length=250)\n\n```\n\nyou can use it as follow:\n\n```python\nasync def get_model():\n    return await  MyModel.objects.async_get(name=\"something\")\n```\n\nyou can also iterate over a query set with `async for`:\n\n```python\nasync def all_models():\n    all_result_set = await MyModel.objects.async_all()\n    async for obj in all_result_set:\n        print(obj)\n```\n\nSome wrappers are also available for template rendering, form validation and login/logout\n\n\n#### Async login\n```python\nfrom django_async_orm.wrappers import async_login\n\nasync def my_async_view(request):\n    await async_login(request)\n    ...\n```\n\n#### Form validation\n```python\n\nfrom django_async_orm.wrappers import async_form_is_valid\nasync def a_view(request):\n    form = MyForm(request.POST)\n    is_valid_form = await async_form_is_valid(form)\n    if is_valid_form:\n        ...\n    \n```\n\n\n# Django ORM support:\n\nThis is an on going projects, not all model methods are ported.\n\n### Manager:\n\n| methods                                  | supported  | comments |\n|------------------------------------------|------------|----------|\n| `Model.objects.async_get`                | \u2705 |  |\n| `Model.objects.async_create`             | \u2705 |  |\n| `Model.objects.async_count`              | \u2705 |  |\n| `Model.objects.async_none`               | \u2705 |  |\n| `Model.objects.async_bulk_create`        | \u2705 |  |\n| `Model.objects.async_bulk_update`        | \u2705 |  |\n| `Model.objects.async_get_or_create`      | \u2705 |  |\n| `Model.objects.async_update_or_create`   | \u2705 |  |\n| `Model.objects.async_earliest`           | \u2705 |  |\n| `Model.objects.async_latest`             | \u2705 |  |\n| `Model.objects.async_first`              | \u2705 |  |\n| `Model.objects.async_last`               | \u2705 |  |\n| `Model.objects.async_in_bulk`            | \u2705 |  |\n| `Model.objects.async_delete`             | \u2705 |  |\n| `Model.objects.async_update`             | \u2705 |  |\n| `Model.objects.async_exists`             | \u2705 |  |\n| `Model.objects.async_explain`            | \u2705 |  |\n| `Model.objects.async_raw`                | \u2705 |  |\n| `Model.objects.async_all`                | \u2705 |  |\n| `Model.objects.async_filter`             | \u2705 |  |\n| `Model.objects.async_exclude`            | \u2705 |  |\n| `Model.objects.async_complex_filter`     | \u2705 |  |\n| `Model.objects.async_union`              | \u2705 |  |\n| `Model.objects.async_intersection`       | \u2705 |  |\n| `Model.objects.async_difference`         | \u2705 |  |\n| `Model.objects.async_select_for_update`  | \u2705 |  |\n| `Model.objects.async_prefetch_related`   | \u2705 |  |\n| `Model.objects.async_annotate`           | \u2705 |  |\n| `Model.objects.async_order_by`           | \u2705 |  |\n| `Model.objects.async_distinct`           | \u2705 |  |\n| `Model.objects.async_difference`         | \u2705 |  |\n| `Model.objects.async_extra`              | \u2705 |  |\n| `Model.objects.async_reverse`            | \u2705 |  |\n| `Model.objects.async_defer`              | \u2705 |  |\n| `Model.objects.async_only`               | \u2705 |  |\n| `Model.objects.async_using`              | \u2705 |  |\n| `Model.objects.async_resolve_expression` | \u2705 |  |\n| `Model.objects.async_ordered`            | \u2705 |  |\n| `__aiter__`                              | \u2705 |  |\n| `__repr__`                               | \u2705 |  |\n| `__len__`                                | \u2705 |  |\n| `__getitem__`                            | \u2705 |  |\n| `Model.objects.async_iterator`           | \u274c |  |\n\n### RawQuerySet\nNot supported \u274c\n\nYou can still call `Model.object.async_raw()` but you will be unable to access the results.\n\n### Model:\n\n| methods                    | supported  | comments |\n|----------------------------|------------|----------|\n| `Model.async_save`                      | \u274c |  |\n| `Model.async_update`                    | \u274c |  |\n| `Model.async_delete`                    | \u274c |  |\n| `...`                                   | \u274c |  |\n\n\n### User Model / Manager\n| methods                    | supported  | comments |\n|----------------------------|------------|----------|\n| `UserModel.is_authenticated`            | \u2705 |  |\n| `UserModel.is_super_user`               | \u2705 |  |\n| `UserModel.objects.async_create_user`   | \u274c |  |\n| `...`                                   | \u274c |  |\n\n\n### Foreign object lazy loading:\nNot supported \u274c\n\n\n### Wrappers:\n| methods                    | supported  | comments |\n|----------------------------|------------|----------|\n| `wrappers.async_render`            | \u2705  |  |\n| `wrappers.async_login`            | \u2705  |  |\n| `wrappers.async_logout`            | \u2705  |  |\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Bringing async capabilities to django ORM",
    "version": "0.1.12",
    "project_urls": {
        "Homepage": "https://github.com/rednaks/django-async-orm",
        "Repository": "https://github.com/rednaks/django-async-orm"
    },
    "split_keywords": [
        "django",
        "async",
        "orm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85cddf12d7ee9a02a402c553c7936c5bb932672b5b3dd2c5f10d1b7b18543ad7",
                "md5": "8222334374a2f993123248de4a5c8582",
                "sha256": "7f23bade57f2764ffaac63dc248e145b6e5a91f59def13b0ca038183e360da4a"
            },
            "downloads": -1,
            "filename": "django_async_orm-0.1.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8222334374a2f993123248de4a5c8582",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 8965,
            "upload_time": "2023-05-11T18:18:25",
            "upload_time_iso_8601": "2023-05-11T18:18:25.570998Z",
            "url": "https://files.pythonhosted.org/packages/85/cd/df12d7ee9a02a402c553c7936c5bb932672b5b3dd2c5f10d1b7b18543ad7/django_async_orm-0.1.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0461758735273595625c143a02f67fea4e33bd0500894fe5b0c2835de9fb2b93",
                "md5": "f1dd52f7fbdb6f1296c4c1461fee9ad4",
                "sha256": "c97e2011eb1e0147473047a229047425e60eaf79f6b6ce37fdbc24f6371436e8"
            },
            "downloads": -1,
            "filename": "django-async-orm-0.1.12.tar.gz",
            "has_sig": false,
            "md5_digest": "f1dd52f7fbdb6f1296c4c1461fee9ad4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 8890,
            "upload_time": "2023-05-11T18:18:23",
            "upload_time_iso_8601": "2023-05-11T18:18:23.757967Z",
            "url": "https://files.pythonhosted.org/packages/04/61/758735273595625c143a02f67fea4e33bd0500894fe5b0c2835de9fb2b93/django-async-orm-0.1.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-11 18:18:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rednaks",
    "github_project": "django-async-orm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-async-orm"
}
        
Elapsed time: 0.10154s