News for hackers. Stuff that matters.
Re:Django 3 by m_ke on Monday December 02, 2019 @09:00AM (#21682298)
Was really excited to upgrade but the async safety check makes the ORM unusable in a Jupyter Notebook.

https://stackoverflow.com/questions/59119396/how-to-use-djan...

https://forum.djangoproject.com/t/is-there-a-way-to-disable-...

Re:Django 3 by andrewgodwin on Monday December 02, 2019 @11:21AM (#21683816)
I've replied to the post on the forum, but if this is the default way Jupyter runs then we're going to have to figure something out longer-term. Calling the Django ORM from an async thread just isn't safe...
Re:Django 3 by m_ke on Monday December 02, 2019 @11:44AM (#21684076)
Thanks for the reply and all of the great work.

Using django in a notebook is definitely not a typical use case so I wouldn't worry about it too much.

Ideally the ORM would be a standalone package that could be used outside of the web server context. (I know sqlalchemy is an option but then you lose all of the benefits of django)

Re:Django 3 by aeyes on Monday December 02, 2019 @05:19PM (#21687675)
Our developers love to work in notebooks running Django, it lets you iterate extremely fast.
Re:Django 3 by m_ke on Monday December 02, 2019 @05:39PM (#21687867)
Andrew already has a PR to fix this issue https://github.com/django/django/pull/12172
Re:Django 3 by jtdev on Monday December 02, 2019 @01:39PM (#21685337)
The ORM has been essentially unusable from my perspective since day 1
Re:Django 3 by dinkleberg on Monday December 02, 2019 @07:30PM (#21688695)
Why is that?
Re:Django 3 by jtdev on Monday December 02, 2019 @09:45PM (#21689458)
Try doing some simple joins, subqueries, unions, etc., and you’ll quickly see why. If you’re able to find the correct incantation, you’ll quickly see that the Django ORM builds awful queries that perform horribly. I’ve found the Django ORM to make simple things hard and hard things harder.
Re:Django 3 by singularity2001 on Monday December 02, 2019 @10:00AM (#21682866)
please tell me that python did not adopt the javascript async hell. async should be an optional keyword on the CALLER side, not an invisible trait of the function. go figure()
Re:Django 3 by m_ke on Monday December 02, 2019 @10:11AM (#21683000)
It didn't, async await is just syntactic sugar on top of coroutines/futures. You can define an sync function and get a coroutine back if you call it without await.

It's still kind of a mess though because you have two universes that are not really compatible, forcing you to rewrite everything that touches IO. For django that probably means a rewrite of the ORM, caching and middlewares.

Re:Django 3 by hajile on Monday December 02, 2019 @11:36AM (#21683983)
JS async/await is also just syntactic sugar on top of Promises (which are basically just futures with the ability to write as well).
Re:Django 3 by jakear on Monday December 02, 2019 @12:01PM (#21684252)
In Javascript, async is an optional parameter on the caller side. (Well, 'await' is, but I figure that's what you mean). It can be used with any function call, not just those that are marked async. Though it only make sense to use it with Promise-returning functions.

Alternatively, you can also use it with a plain Promise, which makes for a nice mutex. I've also used this for imitating async constructors, which is not currently possible.