Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

431
Vistas
Why isn't my javascript not working with django

I am a beginner in django. I have no problem with the back-end but my front-end has some problem with javascript (specifically addEventListener doesn't work). I've tried everything from adding External js to adding internal js nothing seems to work. But the js connect with django and its being loaded, but the function doesn't work and no error seems to log in the console.

It is just a click function, which should toggle a classname in html while clicked. By the way I'm inheriting my nav file. i hope that doesn't cause any problem.

My internal js file:

    <script type="text/javascript">

    // EVENT LISTENER FOR NAV FUNCTION
    let nav_btn = document.querySelector('.user-pr')
    nav_btn.addEventListener('click', navfunc)
    function navfunc() {
        nav_btn.classList.toggle('active')
        console.log("click")
    }
    
</script>

My Settings.py file (Static Config):

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
STATIC_ROOT = os.path.join(BASE_DIR, 'Assets')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

I've checked StackOverflow for similar questions, but nothing match my scenario.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda