Most voted "django-templates" questions
Use this tag for questions about Django’s template engine, which is intended to separate the presentation of a document from your data.
Learn more…118 questions
Sort by count of
-
7
votes2
answers772
viewsDjango and Template
Good night! Guys, I’ve been in trouble for four days and unfortunately I haven’t been able to fix it yet! I’m working with tamplates in Django, but I’m having problems, because nothing appears in…
-
5
votes1
answer139
viewsDjango generating strange code
I am using the visual studio community and created a web project with Django, but when making the homepage, is generating me this code: And the code I have is this: {% load staticfiles %}…
-
5
votes1
answer6199
viewsHow to use Objects.filter in Django?
Good afternoon, I have a model here in my Django Subject, and I want to list it in html, but every subject has as a foreign key the model id category, how I make a variable to receive Objects.filter…
-
4
votes2
answers1225
viewsHow to read and render a.txt file in the Django template?
How do I render the data of a arquivo.txt in a Django template? contents of the archive: 1;'one';'foo' 2;'two';'bar' I return in the template 1 - one - foo 2 - two - bar Any hint where I start?…
-
4
votes1
answer273
viewsDjango: What’s the difference between importing/using include() and not using when configuring a URL?
from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), url(r'^admin/', admin.site.urls), ] In this example I saw that…
-
4
votes1
answer626
viewsTotal and subtotal in Django template using predefined lists
How do I calculate subtotal and total per column? py views. def soma_tuplas(a, b): return (a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3], a[4]) def quotation_list(request): stores =…
-
3
votes1
answer155
viewsReturning the minimum value for comparison in Django template
Following a reply on /a/96503/761 def quotation_list(request): stores = list(Store.objects.all()) products = list(Product.objects.all()) # indice index_store = {store.id: index for index, store in…
-
3
votes1
answer169
viewsHow to change the width of columns in the Admin listing in Django?
How do I specify the width for the columns that are displayed in the Admin listing, more precisely the ones I specify in list_display in admin.py. Researching I found similar question here, where I…
django python-3.x python-2.7 django-templates django-1.8asked 8 years, 11 months ago Marcio Luís 1,061 -
3
votes1
answer856
viewsDjango + Python how to update a table item
Hey, guys, I have a registration flow where in a first step save the student and then the data of the responsible, however, after that I need the student to make a description and this description…
-
3
votes2
answers997
viewsDjango + Python, show modal using {% if %} in template
I’m making a check if there are active classes, if there is should present a modal and not the registration form, but it is not working: py views.: from django.shortcuts import render, redirect from…
-
3
votes2
answers724
viewsConcatenate variables in the Django template
Talk guys, good morning, I have a problem. I’m walking through a lista but I want to concatenar my list I’m calling on template as {{ list }} and {{ forloop.counter0 }} so that in mine is only…
python django list django-templates string-concatenationasked 6 years, 2 months ago Raphael Melo De Lima 461 -
2
votes1
answer64
viewsImproving the return of a specific result
I think I’m letting go of the basics! I have a result that returns me only one element in the dictionary: [{'quant': 236, 'district': 'Centro'}] My context is: context['Districts'] = d How do I make…
-
2
votes1
answer225
viewsQueryset: Getting the description of the accessories on request (Django)
Consider the example below: class Vehicle(models.Model): vehicle = models.CharField(_('veículo'), max_length=50, unique=True) price = models.DecimalField(_(u'preço'), max_digits=8, decimal_places=2)…
-
2
votes1
answer183
viewsDjango - extend admin template
could anyone indicate the best way to extend the Django template? and what is the best way to share a template with the Adminstrative area and the site. I am using Django version 1.8.6 and…
-
2
votes1
answer851
viewsTotal and subtotal in Django template using lists
How do I calculate the subtotal and total per store (store) in the view to play the results in the template? In this case I’m using lists. def quotation_list(request): stores =…
-
2
votes1
answer166
viewsHide CRUD buttons in Django templates for users who are not logged in to the system
I would like to hide my system buttons that allow: add, edit and delete data from my templates for users who are not logged in to the system. He can be seen here:…
-
2
votes1
answer57
viewsInclude in <head> Djanto Templates
I have the following files: base.html: <!-- base.html -- --> <html> <head> <title>Title</title> {% include "head.html" %} </head> <body> Body </body>…
-
2
votes1
answer1306
viewsPython / Django interval of hours
I need to create a schedule of hours: I have the following information in the Django template: Initial time: 08:00 Final time: 18:00 Break in minutes 00:30 I would have been able to implement…
-
2
votes2
answers739
viewsreturn python function variable
I have a function that returns several values, and I wanted to pass two of them out of the function, but when I try it returns that the variable outside the function has not been declared. To…
-
2
votes2
answers164
viewsDjango does not create tables
Greetings to you all. I’m having trouble creating the tables for my apps by Django. I run the PYTHON MANAGE.PY MAKEMIGRATIONS command and it responds: NO CHANGES DETECTED. Then I run the PYTHON…
-
1
votes1
answer284
viewsHow to copy record with Detailview and picking up on pk (Django)
Consider my template: entry_detail.html <form class="navbar-form navbar-right" action="." method="get"> <!-- add --> <!-- <p name="filter_link" class="pull-right"><a…
-
1
votes1
answer3644
views"Noreversematch at/" on Django, when I try to put a link on the button
When I try to put a link on a button appears a page with error of NoReverseMatch at/, I don’t know what else I do, I want to put this link to go to a app registration of users that is called login.…
-
1
votes1
answer92
viewsChanging the template_name in Templateview (Django)
How do I change template_name in Templateview if user is authenticated? Look what I tried class Home(TemplateView): # template_name = 'index.html' is_auth = False def get(self, request): if not…
-
1
votes1
answer179
viewsMany-to-Many: Model and Django Template
I have the following situation: - Budget - Product - Items in the Budget I sought the relationship Many-to-Many in Django (1.10), until then quiet, creates in the Template a Multi-select. But if by…
-
1
votes0
answers153
viewsPandas Dataframe to_html or iterate over the data in the template?
Actually I wanted to iterate on the data in the template? But how do I play my pivot’s dice in context and treat them in the template? df = pd.DataFrame(data) pv = df.pivot(index='cands',…
-
1
votes1
answer71
viewsWhat is the right way to do the template in Django/python?
This has been my first contact with the framework and with mvc/mvt, and I’m in doubt, as a matter of good practices and tals, should I make a template for each of the views or should I just make a…
-
1
votes1
answer69
viewsProblem with urls and views inside the server
I was studying python and Django, and I decided to make my wedding website in January. The project runs perfectly on my local pc, the problem is when I deploy on digital Ocean and it gives that…
-
1
votes1
answer125
viewsDjango. Only change in the database via html
I’ve been developing in Django for a little while, I have an image like on my site, when I click on it I would like to only change a field in the bank without reloading or resending the page and…
-
1
votes1
answer4680
viewsHow to create a form and authenticate Django user
Good night to you all. I am developing a Django project for educational purposes only and I could not find a solution to my problem. I could not generate a form for the user to log in and much less…
python-3.x django login authentication django-templatesasked 7 years, 9 months ago Victor Alessander 387 -
1
votes1
answer2522
viewsProblem with Django form:Integrityerror: NOT NULL Constraint failed
Guys, I’m trying to make a form using model in Django that save the data when I click the button and redirect to a page, well I managed to make the form page, only after putting the necessary data…
-
1
votes2
answers174
viewsDoubt when ranking using Jango!
I’m making a site of a game using Jango and I want to make a ranking based on the score of all users! For now it’s like this: py views.: def index(request): perfis =…
-
1
votes1
answer152
viewsReturn more than one Django data list
I made a homepage using Jango, I am loading my slides and menus dynamically and it was perfect. I put both the menu and the footer through include and it worked 100%. Now I came across a problem,…
-
1
votes2
answers1576
viewsUse {%for %} and {%if %} in Django template
I have 3 videos saved in the Postgres bank where I seventh a star_date and the video only appears on template when the start_date <= date.today() My problem is in template. I have 3 buttons, one…
-
1
votes1
answer47
viewsInvalid block tag
I’m new in Django and I’m having a problem with the tags Template My code: {% load static %} {% block content %} <div> {{ questao.afirmativa }} </div> {% alternativas =…
-
1
votes1
answer133
viewsCreate dialog in Django
I am trying to create a dialog to remove a client in Django (I created the dialog with Materialize), but when trying to remove it does not execute the view function inside the html page. Could…
-
1
votes1
answer593
viewsFormatting Django decimal number template
I’m having trouble displaying the results of a calculation. I have a Decimalfield and want to return it formatted this way: 1.000.000,00 If I order to display normally without tags, it looks like…
-
1
votes1
answer106
viewsPlace the fields of a Django form on the same line
I have a form in Django and in the template I display the fields to be filled: <div id="interval" class="form-inline form-group"> <div class="two wide field"> {% for price in prices %}…
-
1
votes0
answers51
viewsJavascript Datepicker calendar displaying wrong year
I am working with Django and using a datepicker to select the date in a form field: <h3>Data de recebimento</h3> {{ form.creation_date }} <script> $(function () {…
-
1
votes0
answers120
viewsInternal Server Error 500 (Nginx) when I try to generate PDF by Weasyprint
Good morning, you guys. I have a problem in my application and I tried everything and I could not solve. I decided to generate dynamic PDF in my application and for this I used the Weasyprint…
nginx django-templates django-2.0 django-admin internal-server-errorasked 5 years, 5 months ago Alison Andrade 52 -
1
votes3
answers84
viewsTwo classes in a Register screen
-2 I’m starting at Django, and I have some questions: 1° In the code below, as you can see, has a class called Student that has relationship with the Responsible class, I would like to show in a…
-
1
votes1
answer246
viewsDropdown with dynamic options in Django form
I have an expense form that has a field to select the category, but I need the options to be obtained from the database. These days this is mine forms.py: from django import forms from .models…
-
1
votes1
answer161
viewsHow to use a Python function in Django
I’m currently having a problem where I haven’t found any solution that I’ve been able to understand and execute. I will be summarizing here the scope of what I need, otherwise it would be very…
python-3.x django django-templates django-rest-framework django-querysetasked 4 years, 3 months ago Bruno Marques 21 -
1
votes2
answers58
viewsRecover database data on Django
My project is a simple table showing countries, number of covid cases, deaths and recoveries. By Django admin I have already registered two countries and now I want to recover this data and show on…
-
1
votes1
answer51
viewsPerform the action of a form without updating the page on Django
I am developing a project where I need to add members to a group, for this, I go through all registered members and present them in my html template. Each member has next to the "add" button only…
-
0
votes1
answer168
viewsReturning get_FIELD_display from a dictionary-transformed list (Django)
I wanted to turn the following list into a dictionary: lists py. status_list = ( ('c', 'cancelado'), ('elab', 'em elaboração'), ('p', 'pendente'), ('co', 'concluido'), ('a', 'aprovado') ) So I did…
-
0
votes2
answers1451
viewsHow to show Radio Button type fields in the form using Django?
I created a file called const.py (where I have the options of Choices that I will call in the models) as follows:: const. FORENSIC_TRAFFIC_LIGHTING = ( (u'1', u'Boa'), (u'2', u'Ruim'), (u'3',…
-
0
votes0
answers146
viewsDjango error: Invalid block tag: expected 'endblock'
In the development environment works normally, already in the production server I have the following error: Invalid block tag: 'ultimos_produtos', expected 'endblock' Follow the code excerpt: {%…
-
0
votes1
answer514
viewsHow to work with Updateview and Forms in the template
I’m trying to render a client’s data in the template, but I’d like to do it without using it {{ form.as_p }} or {{ form.as_table }} I would like to know if you have any way of using the id of the…
-
0
votes1
answer63
viewsHow to remove elements placed by Django (1.7.5) in the template
Well I’m creating my project template in Django 1.7.5 (I have reasons to use this version and I can’t change it ) but Jango insists on putting these balls, and how it was generated by Jango I don’t…
-
0
votes2
answers442
viewsHow to go to a Django url regardless of the path we are on?
I created a menu in a base file that is visible regardless of the page we are, <p> Tela de perfil <a href="perfil/">Perfil</a></p> The problem is that when we are on the same…