Recently Django 4.1 has been released with a new asynchronous ORM interface. It's really cool. But I've been using it for a couple of weeks now and I found a usecase that made me stuck.
Im trying to replicate this behaviour in an asynchronous context:
class Foo(m.Model):
"""
Stores information about a Foo
"""
name: Union[m.CharField, str] = m.CharField(max_length=49)
foo: Foo = Foo(name='bar')
foo.save()
First of all, the acreate() method does not solve my issue. I need to first create the model instance and then save it.
My guess approach -being consistent with the ORM interface- was to use foo.asave() but the method does not exists.
I'm trying to find a cleaner way to approach this rather than the sync_to_async method.
Thanks a lot for the help! ❤️