From 5dba14b378e3cf29d31f9782651fa4c497123de5 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 21 Nov 2024 07:47:17 +0100 Subject: [PATCH] fix: Use static() for script and style paths Updates script and style paths to use Django's static() function for better path resolution and management. This ensures that the paths are correctly resolved relative to the static files configuration, enhancing maintainability and reliability. --- mood/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mood/views.py b/mood/views.py index 1703f69..1f9f237 100644 --- a/mood/views.py +++ b/mood/views.py @@ -78,7 +78,7 @@ class StatusCreateView(LoginRequiredMixin, CreateView): context = super().get_context_data(**kwargs) context["title"] = "Create Status" context["subtitle"] = "How are you feeling today?" - context["scripts"] = ["frontend/js/dropdown-to-buttons.js"] + context["scripts"] = [static("frontend/js/dropdown-to-buttons.js")] return context def form_valid(self, form): @@ -110,7 +110,7 @@ class StatusEditView(LoginRequiredMixin, UpdateView): context = super().get_context_data(**kwargs) context["title"] = "Update Status" context["subtitle"] = "Change a status you created before." - context["scripts"] = ["frontend/js/dropdown-to-buttons.js"] + context["scripts"] = [static("frontend/js/dropdown-to-buttons.js")] context["buttons"] = [ ( reverse_lazy("mood:status_delete", kwargs={"id": self.kwargs["id"]}), @@ -268,12 +268,12 @@ class MoodEditView(LoginRequiredMixin, UpdateView): context["title"] = "Edit Mood" context["subtitle"] = "Make changes to the mood." context["scripts"] = [ - "colorfield/jscolor/jscolor.js", - "colorfield/colorfield.js", - "frontend/js/fontawesome-iconpicker.min.js", - "frontend/js/iconpicker-loader.js", + static("colorfield/jscolor/jscolor.js"), + static("colorfield/colorfield.js"), + static("frontend/js/fontawesome-iconpicker.min.js"), + static("frontend/js/iconpicker-loader.js"), ] - context["styles"] = ["frontend/css/fontawesome-iconpicker.min.css"] + context["styles"] = [static("frontend/css/fontawesome-iconpicker.min.css")] return context def get_object(self):