Questions tagged [django-templates]
Questions about the template engine of Django, which is intended to separate the presentation of a document from its data.
19,506
questions
0
votes
0
answers
12
views
Django TypeError: issubclass() arg 1 must be a class when trying to create a simple tag
When trying to create a simple tag in django to reassign a variable in a django template, I am getting the error TypeError: issubclass() arg 1 must be a class.
custom_templates.py:
from django import ...
0
votes
1
answer
11
views
dajngo pagination for products, problem with pagination when query
I'm working on a Django project for building a website, and I'm facing an issue when filtering through a search bar by name; the pagination is not working correctly.
When filtering
def mart(request):
...
0
votes
1
answer
22
views
My PostUpdateView does not send any data to form update template
error
I have exactly the same structure for updating forum's posts, so they do work, but the article's ones don't. My article_update_form template simple does not receive any data from the view and ...
-1
votes
0
answers
17
views
<script src="https://js.stripe.com/v3/"></script> stripe submit button not working in django
html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, ...
0
votes
2
answers
17
views
Why when view returns a list of objects from db html file didn't pick the value
def index(request):
context = get_all_tasks()
return render(request, 'sentixplorerapp/index.html',context)
above is my view function when I return this to below html code snippet it return ...
-1
votes
1
answer
36
views
Using Django Templates and Jinja2 Templates Side by Side in the Same Project
I've gone through the Django documentation and checked my Django version (4.2.5) and Jinja2 version (3.1.2).
I'm interested in incorporating Jinja2 for manipulating variables, and in Django templates, ...
0
votes
2
answers
38
views
How to pass dictionary data to chart.js in django?
I want to get a report by chart from my model but I can't figured out how to pass data from a dictionary to chart using chart.js?
here is my model:
class Book(models.Model):
number = models....
1
vote
1
answer
21
views
I want to create a like counter in Django, but I get an error
I want to create a like counter for an exercise project that receives and counts the number of likes from self and displays them in templates .
from django.db import models
from django.contrib.auth....
0
votes
1
answer
24
views
Filtering ManyToMany in Django-Admin/Django-Form by related field
I want to filter my ManyToMany by related fields in the Django-Admin (create/edit object). For example i have 3 Models:
Model 1 - Boardgame: Name (CharField), Genre (ForeignKey)
Model 2 - Location: ...
0
votes
2
answers
39
views
I was trying to create register page by using `UserCreationForm` but getting empty `QueryDict` from post method
I was trying to create register page by using UserCreationForm but getting empty QueryDict from post method when I print it on console. There is no errors. I did research on it but could not figure ...
0
votes
1
answer
28
views
Formatting text in Python
I currently have a breadcrumb package which have successfully deployed into my website. The package displays the name of the name of the html document which is gleamed from the web directory.
I'm ...
-1
votes
0
answers
6
views
Error while adding exiting table from sql server in django app using django inspectdb -- error
I am try to use py -m django inspectdb , but not able to get success...
I am able to connect database through django code in setting.py
I am getting following error while using inspectdb command in ...
0
votes
0
answers
14
views
Django custom middleware doesn't caches sometime
I am trying to make a multi tenant website. For example a.com and b.com websites runs same home.html but it's values changes by it's domain name. But my middleware doesn't caches sometimes.
I added my ...
-1
votes
0
answers
20
views
Is there a django plugin that produces documentation for the template inheritance structure?
The django.contrib.admindocs plugin provides a nice link in the admin view to a variety of documentation around the data models. Is there a similar plugin that provides a diagram or description of how ...
0
votes
1
answer
16
views
Django Template Folder Naming
Preface
I have a Django project called shopping_list and an app in that project called main with this structure. the main page of the main app will use main.html as a template
.
├── main
│ ├── ...
0
votes
0
answers
24
views
Django canvas charts disappear after HX-GET
I'm working on a Django project using MDBootstrap to display charts using canvas. Initially, everything works perfectly. However, when I update the information on the dashboard using Htmx's HX-GET, ...
1
vote
1
answer
24
views
how can redirect to another page when if statement is true in django template?
I have a HTML page that displays some information retrieved from database, in this template i have if statement when it is return True, it must be redirect to another page,
here is my HTML Page:
...
0
votes
1
answer
11
views
Creating unique aria labels in (nested) for loops
I've a django template that creates a lump of content by looping over some data
The relevant fragment is:
{% for c,v in landlords.items %}
{% with cloop=forloop.counter %}
<section class=&...
0
votes
0
answers
6
views
Django templates issue
I have installed django current version with venv I facing an issue with templates when I'm creating index.html this show an truncatechar_html suggestion in place of html:5 while I have setup ...
0
votes
1
answer
26
views
Master template for airium
I am using airium as a replacement for the default Django templates system. In the default Django system the concept of master template is used to give a common frame and look to all the pages of a ...
0
votes
1
answer
23
views
How do I check if a date in the database is past due in my template
I'm new to Django so I apologize if this is something simple.
I'm trying to check if a date stored in the database is past due.
I have a "due_date" in my "Update" model and would ...
0
votes
1
answer
15
views
Can I assign a combination of variables using one "with" template tag?
I have the template code value="{{ key|slice:":4" }}-{{ suggestion.pk }}" which slices the variable key, appends a "-" and the value of suggestion.pk. I now want to ...
0
votes
1
answer
15
views
How to reuse Django Model Form with changed labels?
Inside a Django app I have a Person model that I want to use in a form to capture both student and teacher data. The fields are identical in both forms, but the labels should be different. How can I ...
-1
votes
0
answers
30
views
JavaScript: how to add a new element in certain position
I'm new to JS and I need to add new timeline element in certain position in html. How can I do that?
Here is my JS script which makes websocket connection and changing race field. So, in this script I ...
0
votes
2
answers
23
views
conditions on django generic detailview
I'm trying to show a post detail view only when post.status=='pub'. I did it in list view with overriding get_queryset method but how can i do the same with detail view?
I want the detail view to ...
1
vote
0
answers
27
views
Render Serialized data in django rest framework
I'm new to django and web development and wanna know how to render html with serialized data which i use for my api's
here's my files:
Views.py
class IngredientsViewSet(ModelViewSet):
...
0
votes
1
answer
24
views
How to edit data in crud operations in django
I am trying to make CRUD app in django
I am trying to collect data from form and trying to display the data in form of tables
So the user can read, delete, update or delete the data
I completed other ...
0
votes
1
answer
24
views
it shows OS error if i try to open the links
i am making a webpage which looks like this using django :
the webpage
while opening the links , it shows OS error :
[Errno 22] Invalid argument: 'C:\Users\Lenovo\Desktop\django projects\env\Lib\site-...
0
votes
1
answer
19
views
Is there a best practice to avoid Django's "Found another file with the destination path" during collectstatic on production?
So I'm using Django 4.2, with Django-JET admin package via Django-jet-reboot fork; it enhances Admin with nice functionality and UX.
Each time I deploy my app on production, it feels its taking much ...
1
vote
1
answer
22
views
Template behavior depends on actual class of an instance in a class hierarchy
In django I have a model A and 3 derived models D1, D2, D3. I also have a ManyToManyField in another model B that references instances of A that can be instances of D1s, D2s or D3s. In the template, ...
0
votes
0
answers
19
views
i cant send query_set as context argument to the render method
im trying fetch data from db and display it into the page, i get the data properly form db but cant display it.
view.py
from books.models import Book
from django.shortcuts import render
def query(...
1
vote
0
answers
29
views
Can't add to head in Django Template
I have the following:
bootstrap.html:
{% extends 'django_bootstrap5/bootstrap5.html' %}
{% block bootstrap5_title %}{% block title %}{% endblock %}{% endblock %}
sm/base.html:
{% extends 'sm/...
0
votes
0
answers
28
views
Django-templates: how to make list in templates
The part of my template:
{% if True %}
<div class="container" id="timeline-block">
<div class="row">
<div class="panel-timeline">
...
0
votes
0
answers
14
views
Editing HTML with ChartJS Django
Can you help with editing HTML with ChartJS Django?
When I am adding {% extends 'base.html' %} to the HTML with ChartJS it returns me the page only base.html without charts (and when removing base....
1
vote
1
answer
29
views
Access the rows of a model B through a list of foreign keys of B
I have 2 models A & B in django, A stores a list of foreign keys to B in a JSONField. In the template, how do I retrieve the B instances from the B foreign keys stored in A?
models.py
class B(...
0
votes
1
answer
29
views
I got this error while making migration . module got error and for frozen importlib
I like to get file in postgreSQL . so i want to do migration so i got these error.
there is more than model error like frozen importlib like error so help me to clear the error.
I Expect the code and ...
1
vote
1
answer
19
views
Phython getting issue with urls path
I'm learning pyhton django, and I created a file nosotros.html inside of templates/paginas:
and on views.py my I have:
from django.shortcuts import render
from django.http import HttpResponse
# ...
-1
votes
0
answers
28
views
Django: websockets for dynamic updates in real time to a django template (only this way, no Ajax etc.)
Can you please help me with dynamic update in template. I've found a lot of tutorials, but all of them are so different. It would be better to get an advice for my specific situation.
So, that's the ...
0
votes
1
answer
33
views
How can I return different field foreign key for two models related it
I want to retrieve the field full name for the field author in book creation,
and the nickname to retrieve in article creation.
models.py :
class Author(models.Model):
full_name = models.CharField(...
0
votes
0
answers
8
views
Static Files (Including Images) Not Displaying in Django Web App After Deployment
I have developed a web app using Django, and during development, all my static files, including images, were displayed correctly. However, after deploying the project, the images are not being ...
0
votes
0
answers
12
views
CS50W network project4 edit feature
I got problem when i tried to edit the content of a post and clicked save,i found that on console:POST http://127.0.0.1:8000/edit/27 500 (Internal Server Error)
handleSave @ Inline Babel script:17
...
1
vote
0
answers
15
views
Unable to capture record IDs for Bulk Updating Fields for non-admin users in Django Front End
I'm trying to bulk update fields for a list of records, similar to an Admin Actions type drop down list , for non-admin users in the front end.
The process a user follows -
Step 1. Come to the ...
0
votes
0
answers
21
views
Django Website Not Displaying Expected Content
I'm new to Django and am building a site for reminders. However, I see a blank page on launch. My base.html has a form for reminders and a display section, index.html has a similar form, and styles....
-1
votes
2
answers
25
views
I have restarted My Django for Other Project But it's still trying to load Previous project files
I have worked on Django Project where I create applications hello, newyear, and tasks. Now, I have to
work on a different Project I got it's file from CMD I opened it in visual studio and then created ...
0
votes
0
answers
20
views
Bootstrap 5 with centering issues on Django template
The second element of my cart, which in this case is a nike product, is not aligned and centered like the others.
I would like to know where the problem is in centralizing this element so that it ...
0
votes
2
answers
14
views
Can i make one static files that used in all apps?
Im using Django and i want to make a **static **file that can used in all apps templates
this is the tree of my project
C:.
├───AISystem
│ ├───static
│ │ ├───css
│ │ ├───imgs
│ │ │ ├───...
1
vote
1
answer
25
views
Django - Form Not Saving Image on Form Submission
For my current ModelForm for some reason all the fields get updated on a form submission as they are supposed to except for the image field.
What’s the best solution to get this working with my ...
0
votes
0
answers
18
views
How to use pipeline method in django using library social-auth-app-django
I create an django project name is registration in this project I build an app name is mainApp so in this project I have to create sign in with google functionallity so this I have done it now I want ...
0
votes
0
answers
14
views
Interactive Table Tree Structure (Datatable) in Django Bootstrap4 & Ajax
I have a project model that can have WBS and activities, WBS can also have activities.
I want to load it in a tree table style so the user can edit any one record from one screen. Is it possible in ...
0
votes
0
answers
29
views
Errors with Deploying a Django and React App to Railway
I'm struggling to deploy my django app to railway. The app continues to successfully deploy to Railway, however when visiting the URL of my railway app, I continue to get the error: ...