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

3.1K
Vistas
django drf login template

I extend the login template of DRF

{% extends "rest_framework/login_base.html" %}
{% block branding %}
  <h3 style="margin: 0 0 20px;">My site</h3>
{% endblock %}

with urls.py:

urlpatterns = [
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^login', login, template_name, name='login'),
    url(r'^logout', logout, template_name, name='logout'),
...

Everything works well except if the connection fails: DRF redirect to http://127.0.0.1:8000/api-auth/login/ instead of http://127.0.0.1:8000/login/ and my extended template is not used. So I lose my site name for "Django REST framework" title.

Regards

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Put the template in templates/rest_framework/ and

urlpatterns = [
    url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
about 4 years ago · Santiago Trujillo Denunciar

0

If you extended it on project/templates/rest_framework/login.html:

{% extends "rest_framework/login_base.html" %}
{% block branding %}
   <h3 style="margin: 0 0 20px;">My site</h3>
{% endblock %}

The name of your project's login form which is 'my site', shouldn't change.

For the unified resource locator you can try this:

    url(r'^', include('rest_framework.urls', namespace='rest_framework')),

So that upon redirection the url will be like in the below sample:

http://localhost:8000/login/
http://127.0.0.1:8000/login/
about 4 years ago · Santiago Trujillo 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