Are they possible?
something like this?
@register.simple_tag
async def do_something(uuid):
try:
obj = Model.objects.aget(uuid=uuid)
except Model.DoesNotExist:
return ''
return f'<a href="/{obj.url}">{orb.title}</a>'
When called from a template, using {% do_something 'bbccf148-5c08-4958-8a8c-2f8c93469f01' %}
all I get in the output is:
<coroutine object do_something at 0x7f895a85a500>
Any ideas? ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
I’ve got a pretty good idea that nothing has significantly changed in the rendering engine regarding asynchronous processing in the 9 months since you last asked about this.
I see no evidence that the render process works in anything other than a synchronous mode.
I have the same problem. If sync function is used in custom tag, it throws “You cannot call this from an async context - use a thread or sync_to_async”.
If async function is used then it always returns coroutine object.
Upd: using sync function with os.environ[“DJANGO_ALLOW_ASYNC_UNSAFE”] = “true” in settings.py hepled as temporary solution.