** I use Weasyprint to generate pdf from HTML. When running the application in ASGI static files are not loaded in pdf, but if I run the application in WSGI then the static file loads correctly. How can I solve this issue?**
This part is generating pdf.
HTML(string=html_string,base_url=self.request.build_absolute_uri()).write_pdf(response,stylesheets=[css],presentational_hints=True,font_config=font_config)
asgi.py
application = ProtocolTypeRouter({
"http": application,
"websocket": AuthMiddlewareStack(
URLRouter(
notification.routing.websocket_urlpatterns
),
),
# Just HTTP for now. (We can add other protocols later.)
})
routing.py
websocket_urlpatterns = [
re_path(r'ws/notification/(?P<user_id>\w+)/$', consumers.NotificationConsumer.as_asgi()),
#re_path(r'ws/notification-main/(?P<user_id>\w+)/$', consumers.NotificationConsumerMain.as_asgi()),
re_path(r'ws/loginstatus/(?P<token>\w+)/$', consumers.LoginStatus.as_asgi()),
#path('ws/notification/<user_id>/', consumers.NotificationConsumer.as_asgi()),
]