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

587
Vistas
How to connect Django Rest API to a html CSS JS frontend

I am new to programming and one thing I am very confused about, my boss has told me to create a rest API about an app which I have completed all the signups, login, and other parts. But now I have to create a frontend but all the tutorials on the internet are about create rest API of Django to react or some other frontend framework, is their any tutorial on YouTube about connecting to a html CSS JavaScript on frontend to Rest API. thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you don't want a frontend just follow the official django tutorial to learn how to serve html/css/js from django.

From there you can either pass the data you need from your api down through the django context, or you can use fetch or something similar to grab it from javascript.

The latter would look like this.

# views.py
def index(request):
    return render(request, 'index.html')

def apiview(request):
    return JsonResponse({'title', 'served from api'})

index.html
<div class="title" token={{csrf_token}}></div>
<script>
function getTitle() {
    const div = document.querySelector('title')
    const csrf_token = div.getAttribute('token')
    fetch('localhost:8000/apiview', {
        method: 'get',
        headers: {'X-CSRFToken': token}
    })
    .then(data => data.json())
    .then(data => div.innerHTML = data.title)
}
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
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