Category : django-templates

I try to build a blog and this blog consist of posts and these posts have comments, When I add comment to the first post it adds succussfuly but when I try to add comment the second or third this error raise ValueError: The view videos.views.add_comment_post didn’t return an HttpResponse object. It returned None instead. ..

Read more

this is my views.py file def xyz(request): year="Dec 24, 2021 10:40:44" return render(request,"abc.html",{"year":year}) this is my HTML file <script> (function () { let birthday = {{year}}, countDown = new Date(birthday).getTime(), x = setInterval(function() { ….. ….. ….. </script> i am not able to accept the value of year in let birthday variable I actually want ..

Read more

How can i directly convert the string into number in template literals in javascript? Actually i am working on django templating for loop. My HTML is: <div class="container"></div> <button id="bt">Button</button> My views.py is: addpost = list(addPost.objects.filter(category=’Technology’).values()) context = json.dumps({"addDict":addpost}) return render(request, "blog/technology.html", {"addDict":context, "addpost":addpost}) My Javascript code: <script> var data = JSON.parse("{{addDict|escapejs}}"); data = data["addDict"]; ..

Read more

My project was working perfectly fine, i don’t know what happened. I didn’t even make any changes to front end, i was working on back end. On reloading my website to check a feature, suddenly all of my css disappeared. On checking the console, there were messages like: The resource from “http://127.0.0.1:8000/static/events/css/profile.css” was blocked due ..

Read more

I have a form where I want to do some extra confirmation (via a modal) in a certain case. Since this is based on an email field, I’d like to validate that field before dropping into the modal. I’m doing this in JS: const newEmailField = document.getElementsByName(‘new_email’)[0] const newEmailError = document.createElement(‘p’) newEmailError.innerHTML = ‘<strong>Enter a ..

Read more

What would be the corresponding jQuery function or Ajax function to change these toggle values so that if the toggle switch is on the value would be changed to True? forms.py from django import forms class CsvForm(forms.Form): shipping_us = forms.BooleanField(required=False) shipping_europe = forms.BooleanField(required=False) shipping_asia = forms.BooleanField(required=False) views.py def submit(request): csv_form = ” if request.method == ..

Read more

I’ve got a set up where I have a table generated with HTML, something like this: <tbody> {% for key, value in appointments.appointments.items %} <tr onclick="" class = "green-background appt-row"> <td class = "info-row form-select {{key}}">{{ value.person }}</td> <td class = "info-row {{key}}">{{ value.time }}</td> <td class = "info-row {{key}}">{{ value.number }}</td> <td class = ..

Read more