Skip to main content

Bringing async capabilities to django ORM

Project description

Downloads

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:

INSTALLED_APPS = [
    ...,
    'django_async_orm'
]

Usage

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

example:

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

you can use it as follow:

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

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

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

from django_async_orm.wrappers import async_login

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

Form validation

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

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

django-async-orm-0.1.12.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

django_async_orm-0.1.12-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file django-async-orm-0.1.12.tar.gz.

File metadata

  • Download URL: django-async-orm-0.1.12.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/6.2.4-060204-generic

File hashes

Hashes for django-async-orm-0.1.12.tar.gz
Algorithm Hash digest
SHA256 c97e2011eb1e0147473047a229047425e60eaf79f6b6ce37fdbc24f6371436e8
MD5 f1dd52f7fbdb6f1296c4c1461fee9ad4
BLAKE2b-256 0461758735273595625c143a02f67fea4e33bd0500894fe5b0c2835de9fb2b93

See more details on using hashes here.

File details

Details for the file django_async_orm-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: django_async_orm-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/6.2.4-060204-generic

File hashes

Hashes for django_async_orm-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7f23bade57f2764ffaac63dc248e145b6e5a91f59def13b0ca038183e360da4a
MD5 8222334374a2f993123248de4a5c8582
BLAKE2b-256 85cddf12d7ee9a02a402c553c7936c5bb932672b5b3dd2c5f10d1b7b18543ad7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page