gorgeous-airport-54386
10/23/2021, 3:01 PMpython
def hx_render(fullpage, partial):
def decorator(func):
@wraps(func)
def wrapper(request, args, **kwargs):
context = func(request, *args, **kwargs)
if request.htmx:
return render(request, partial, context)
else:
return render(request, fullpage, context)
return wrapper
return decorator
i haven't touched python in a while and i also don't have django experience, so take this with a grain of salt