Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==5.0
djangorestframework==3.16.0
Django==5.1.10
djangorestframework==3.16.1
django-filter==25.1
Markdown
gunicorn
Expand Down
3 changes: 3 additions & 0 deletions web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,6 @@

# CSRF trusted origins
CSRF_TRUSTED_ORIGINS = os.getenv("DJANGO_CSRF_TRUSTED_ORIGINS", "").split(",")

# To direct django admin login into the built-in admin login page
LOGIN_URL = "/admin/login/"
2 changes: 2 additions & 0 deletions web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib import admin
from django.views.generic.base import RedirectView
from django.urls import path
from views import DRFLoginView

admin.autodiscover()

Expand All @@ -10,6 +11,7 @@
path("admin/", admin.site.urls),
path("api/", include("services.urls")),
# should be in services/urls.py
path("api-auth/login/", DRFLoginView.as_view(), name="rest_login"),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
path("", RedirectView.as_view(url="/api/", permanent=True)),
]
18 changes: 16 additions & 2 deletions web/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.contrib.auth.views import LoginView


def home(request):
return render_to_response("home/home.html")
return render(request, "home/home.html")


class DRFLoginView(LoginView):
template_name = "rest_framework/login.html"

def get(self, request, *args, **kwargs):
context = {
"form": self.get_form(),
"next": request.GET.get("next", ""),
"name": "Login",
"code_style": "friendly",
}
return render(request, self.template_name, context)