You can profile functions locally by enabling Django Silk by setting the environment variable: ENABLE_SILK
to on
in your .env
file. If your local environment is already running, you will need to restart the web application via: docker-compose restart web
Once enabled, you may use silk
by decorating methods with @silk_profile
. For example:
from silk.profiling.profiler import silk_profile
@silk_profile(name='View About')
def about(request):
context = {
'active': 'about',
'title': 'About',
}
return TemplateResponse(request, 'about.html', context)
You may view the profiling results by visiting: http://localhost:8000/silk