Using wavesurfer.js locally in a Django app

90 views Asked by At

I downloaded wavesurfer.js from GitHub and added the folder in my django app. I searched through the folders and subfolders but couldn't find the wavesurfer.min.js or whatever the JavaScript file is. I want to be able to add the JavaScript to my HTML template.

I need help with this as I don't want to use the CDN link. Thank you all.

1

There are 1 answers

6
Pycm On

Look here

Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS.

  1. go in to your static folder

  2. copy js file from download folder to this static folder

  3. if you don't have static folder > create folder call "static" inside app folder

  4. add static root and static url settings to settings.py

    STATIC_URL = "static/" 
    
  5. add static urls to project urls.py for debug = true

    from django.conf import settings
    from django.conf.urls.static import static
    
    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 
    
  6. add <script type="text/javascript" src="{% static "relative path to your js file from static folder /my_external_script.js" %}"></script>