I try to do this:

url( regex=r'^(?P<jsfile>[^/]+).js/$', view=views.JSfileDetailView.as_view(), name='detail' ), 

With such views :

 class JSfileDetailView(LoginRequiredMixin, DetailView): model = JSfile #pk_url_kwarg = 'jsfile' slug_field = 'jsfile' slug_url_kwarg = 'jsfile' template_name = 'jsfiles/jsfile_detail.js' 

Trying to render simply js , at the output it turns out inside the <body></body> , and naturally, it is not possible to use it as js

How to be? Has anyone encountered a similar problem?

    1 answer 1

    It was only necessary to specify the content_type :

     class JSfileDetailView(LoginRequiredMixin, DetailView): model = JSfile #pk_url_kwarg = 'jsfile' slug_field = 'jsfile' slug_url_kwarg = 'jsfile' template_name = 'jsfiles/jsfile_detail.js' content_type = 'application/javascript' 

    Learned here