django-templates Questions

2

As described in the documentation, since 4.1 the default behavior for template loading changed drastically. If I understand it right, until 4.0 it worked like this: With DEBUG enabled, the templat...
Beachlamar asked 27/9, 2022 at 13:48

3

I'm trying to retrieve data from the database and render it in rows of three columns. I've tried as many methods as I could find, finally it seemed to be rendering with this code: <div class='co...
Cecilacecile asked 26/10, 2022 at 5:34

4

Solved

This is how it is structured The code inside apps.py of accounts folder file is from django.apps import AppConfig class AccountsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoFi...
Leyden asked 18/3, 2022 at 15:53

5

Solved

I'm new to Django and I wonder if there is a way to dump all the variables available to a template for debugging purposes. In Python I might use something like locals(), is there something equivale...
Shit asked 14/1, 2010 at 19:25

8

Solved

i want to compare num and {{buildSummary_list.number}}, but why it is not work? And i got an error Could not parse the remainder: '{{buildSummary_list.number}}' from '{{buildSummary_list.number}}...
Sikorsky asked 25/8, 2010 at 2:57

6

Solved

The JS snippet I created relies on the forloop.counter variable being available within a {% for key, value in data.items %}..{% endfor %} tag. Is there a way to use mathematical operators (*, -, ...
Sybarite asked 20/8, 2013 at 9:30

2

Solved

In my Django template, I am using the list of objects in a drop down menu. I am processing it based on the selection. The HTML Template: <select id="org" name="org_list" onChange="redirectUrl...
Soppy asked 5/12, 2011 at 18:15

6

How would I go about speeding up Django template rendering? My template takes about 1-2 seconds or so to render, after the view function fully computes whatever it needs to. I've already at...
Durian asked 20/12, 2011 at 0:26

11

Solved

I love VSCode on-save auto-format, until it messed up with my template code. It wrongly formats my django template syntax into one line code (sometimes really long line). So instead of having this ...
Sensualist asked 10/2, 2017 at 23:55

1

I have category and subcategory store in my database, and subcategory is related to category, I have multiple pages on my website, but I am able to display category in the menu on some pages, but I...

6

Solved

I'm passing to Django's template a function, which returns some records. I want to call this function and iterate over its result. {% for item in my_func(10) %} That doesn't work. I've tried...
Jeanelle asked 18/3, 2010 at 9:53

3

Solved

I am using distinct to get the distinct latest values but it is giving me an error: DISTINCT ON fields is not supported by this database backend views.py class ReportView(LoginRequiredMixin, ...

6

Solved

I'm using: {% extends "base.html" %} I get the following error: <ExtendsNode: extends "base.html"> must be the first tag in the template. Can you please help me?
Shayshaya asked 10/8, 2010 at 18:57

5

Solved

I've got a field in my model of type FileField. This gives me an object of type File, which has the following method: File.name: The name of the file including the relative path from MEDIA_ROOT...
Manuelmanuela asked 21/4, 2010 at 14:9

23

I just want to drop the favicon.ico in my staticfiles directory and then have it show up in my app. How can I accomplish this? I have placed the favicon.ico file in my staticfiles directory, but ...
Cutwater asked 21/2, 2014 at 15:9

8

Solved

I'm trying to translate a Django app. I created some strings with {% trans %} in my templates. However, when I execute the following command in my app folder, I receive an error message: $ django-a...
Coruscation asked 24/7, 2014 at 14:53

2

specifically, using the example template in the django-filter docs: {% extends "base.html" %} {% block content %} <form action="" method="get"> {{ filter.form.as_p }} <input type="subm...
Osborne asked 26/2, 2014 at 15:36

5

Solved

I want to use Jinja2 and Django crispy forms together, but when I load crispy_forms_tags in my template and trying to render form with this template tag, I get an error: Encountered unknown tag 'c...
Magnetic asked 18/8, 2014 at 13:49

1

I have the same code block in four of my functions. Is there a way that can avoid repeating the same code block? Here is the same code block: def function_name(): # ...some code... hot_news_48h =...
Groschen asked 17/8, 2018 at 22:55

2

Solved

I'm trying to iterate a dictionary of dictionary in Django template page {% for (key_o, value_o) in f_values.items() %} <tr class="row {% cycle 'odd' 'even' %}"> {% for (key_i, val_i) in ...
Pneumonia asked 8/3, 2011 at 10:25

6

Solved

I have some loop on the page and need list item depending from loop number. When I call: {{ mylist.1 }} {{ mylist.2 }} {{ mylist.3 }} all works fine but what I really need is something like: ...
Imbibition asked 20/1, 2012 at 22:1

5

I have a navbar menu with a list of links which i want to show the active link when the user is on the page, so far i have managed to do this with links that dont have dropdowns like this. But I...
Purusha asked 7/10, 2017 at 6:29

5

Solved

I want to check if a value belongs to a list in django template. Something like this {% if value in ['Pass','Fail'] %} How can I achieve this?
Denning asked 20/9, 2011 at 7:46

3

Solved

In my Django Templates, I want to pass in a string as follows: trademard = "MyCompany ™" and it will show up as the correct HTML entity of TM However, when it is passed in, ™ is...
Quagga asked 30/6, 2014 at 19:44

2

Solved

I am running Django on a local Vagrant arch machine on a Win7 host. I set up my environment variables from Django in a .env file. In my app all static files are served correctly and everything work...
Skull asked 5/4, 2017 at 7:41

© 2022 - 2024 — McMap. All rights reserved.