• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bringing Async Capabilities to django ORM

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.

note: Only non-existing methods will be patched.

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.aget(name="something")

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

async def all_models():
    all_result_set = await MyModel.objects.aall()
    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 alogin

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

Form validation

from django_async_orm.wrappers import aform_is_valid
async def a_view(request):
    form = MyForm(request.POST)
    is_valid_form = await aform_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.aget
Model.objects.acreate
Model.objects.acount
Model.objects.anone
Model.objects.abulk_create
Model.objects.abulk_update
Model.objects.aget_or_create
Model.objects.aupdate_or_create
Model.objects.aearliest
Model.objects.alatest
Model.objects.afirst
Model.objects.alast
Model.objects.ain_bulk
Model.objects.adelete
Model.objects.aupdate
Model.objects.aexists
Model.objects.aexplain
Model.objects.araw
Model.objects.aall
Model.objects.afilter
Model.objects.aexclude
Model.objects.acomplex_filter
Model.objects.aunion
Model.objects.aintersection
Model.objects.adifference
Model.objects.aselect_for_update
Model.objects.aprefetch_related
Model.objects.aannotate
Model.objects.aorder_by
Model.objects.adistinct
Model.objects.adifference
Model.objects.aextra
Model.objects.areverse
Model.objects.adefer
Model.objects.aonly
Model.objects.ausing
Model.objects.aresolve_expression
Model.objects.aordered
__aiter__
__repr__
__len__
__getitem__
Model.objects.aiterator

RawQuerySet

Not supported

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

Model:

methods supported comments
Model.asave
Model.aupdate
Model.adelete
...

User Model / Manager

methods supported comments
User.is_authenticated
User.is_super_user
User.objects.acreate_user
...

Foreign object lazy loading:

Not supported

Wrappers:

methods supported comments
arender
alogin
alogout

More Repositories

1

django-ip-geolocation

IP Geolocation Hooks for django
Python
34
star
2

matrix-webhooks

Rich content for matrix channels
Python
10
star
3

git-hook-commit-ref

git hook to add a reference to your commit message
Rust
7
star
4

remoteCMD

remote command line
C
6
star
5

EspritLibreBot

Esprit Libre IRC Bot
Python
6
star
6

airfree-wt

AirFree-Wireless Toolkit
Python
4
star
7

Twitter-Math-Bot

Python
3
star
8

MzTn-Tweet

A Twitter Extension for firefox
JavaScript
3
star
9

firecam

FirefoxOS webcam server
JavaScript
3
star
10

goatmo

dht22 prometheus exporter written in golang
Go
3
star
11

Chatzilla-Sidebar

Chatzilla Tweak
3
star
12

multigit-rs

Rust
2
star
13

connectme

connectme
Python
2
star
14

simpleWS-python

Python
2
star
15

Mouse-Emu

Mouse Emulator
C++
2
star
16

MzTnTranslator

Firefox extension, that makes your life easer !
JavaScript
2
star
17

google-translate-alternative-api

An alternative api to google translate !
Python
2
star
18

vim-split-term

NeoVim Plugin open new terminal in new splitted window
Vim Script
2
star
19

Template-Creator

Template Creator
Python
2
star
20

b3-tracker

tracking bulletin 3 (B3)
Python
1
star
21

fakeAddressChecker

JavaScript
1
star
22

dailyProgrammer

http://www.reddit.com/r/dailyprogrammer
C
1
star
23

PresManager

1
star
24

appendedNewTab

JavaScript
1
star
25

rust-move-ref-clone-bench

Rust
1
star
26

GitSlides

CSS
1
star
27

Translater

This project is a tester of Alex API (google translate alternative API)
C
1
star
28

Git-Switcher

Shell
1
star
29

skanderBot

Python
1
star
30

evosect

Python
1
star
31

zapetta

HTML
1
star
32

SAE_crypto_driver

Ma solution pour l'examen SAE
C
1
star
33

todo-redux-purejs

a PoC to demonstrate we still can use raw javascript to build webapps with redux-state management.
JavaScript
1
star