django-templates Questions

3

Solved

How can I group checkboxes produced by CheckboxSelectMultiple by a related model? This is best demonstrated by example. models.py: class FeatureCategory(models.Model): name = models.CharField(m...
Savil asked 16/12, 2012 at 1:15

6

Solved

I have basic application with admin panel and direct_to_template home page. When I type url which does not match any from urls I receive 404 error, but when I set DEBUG to false I receive 500.html ...
Harden asked 2/3, 2011 at 12:19

7

Solved

I have an input field that is rendered with a template like so: <div class="field"> {{ form.city }} </div> Which is rendered as: <div class="field"> <input id="id_city" t...
Jordon asked 25/5, 2010 at 4:27

6

Solved

I'm working on a project and following the documentation. I didn't succeed to include javascript. Here is my settings: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "st...

6

I need to set up a favicon for django admin interface. It would be best to do it globally, without overriding templates for all apps. What is the cleanest way to do it? I tried searching Django...
Grane asked 23/1, 2016 at 5:14

18

Solved

I am trying to write a Bootstrap Form with Django ModelForm. I have read the Django Documentation Django Documentation about Forms, so I have this code: <div class="form-group"> {{ ...
Brucebrucellosis asked 18/4, 2015 at 10:29

20

How do I write a numeric for loop in a Django template? I mean something like for i = 1 to n
Papillon asked 10/7, 2009 at 4:48

2

Solved

I'm new to django and can't find a way to get this to work in django templates. The idea is to check if previous items first letter is equal with current ones, like so: {% for item in items %} {%...
Feeze asked 21/10, 2010 at 9:49

20

Following the tutorial found here exactly, I cannot create a custom 500 or 404 error page. If I do type in a bad url, the page gives me the default error page. Is there anything I should be checkin...
Phenazine asked 15/7, 2013 at 20:7

3

Solved

I am creating a very basic Django messaging application, and would like to use htmx to send and render messages. I am able to post, save the message, and render the partial message without issue. H...
Ramose asked 20/11, 2021 at 4:23

7

When particularly extend template and when to use include? Is include of any use with content like user profile section (like about me in the corner of our site)?
Megillah asked 19/5, 2010 at 7:48

4

I am trying to use a for loop in my template but I am getting an error. Here is the Jinja: {% for i in range(1,10) %} <h2>{{i}}</h2> {% endfor %} Here is the error: django.template.e...
Alphonsa asked 6/2, 2018 at 7:0

7

I've just started learning Django and followed their tutorial to the letter. I've tried to set up the website three times, every time I was greeted with the same error (in the title). Again, follow...
Zamboanga asked 9/2, 2013 at 13:7

7

Solved

I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site, in my template, I have: {% if user.get_...

6

I was trying to use the url template tag in django, but no lucky, I defined my urls.py like this urlpatterns = patterns('', url(r'^analyse/$', views.home, name="home"), url(r'^analyse/i...
Altar asked 22/11, 2009 at 2:25

10

Solved

I am getting this issue when I type localhost:8000/admin/. `TemplateSyntaxError: Could not parse the remainder: ':password_change' from 'admin:password_change'. The syntax of 'url' changed in Djan...
Lenzi asked 17/10, 2013 at 13:49

7

Solved

I have looked a lot on google for answers of how to use the 'url' tag in templates only to find many responses saying 'You just insert it into your template and point it at the view you want the ur...
Selfsustaining asked 4/1, 2011 at 23:13

10

How can I get information about the logged-in user in a Django application? For example: I need to know the username of the logged-in user to say who posted a Review: <form id='formulario' metho...
Determine asked 3/6, 2013 at 21:57

10

Solved

What is the best location to put templates in django project?

6

Solved

My app's urls.py is: from django.urls import path from . import views app_name = 'javascript' urlpatterns = [ path('create_table', views.create_table, name='create_table') My views.py is: def cr...
Selma asked 15/3, 2018 at 21:58

9

Is there a way to check for an empty query set in the Django template? In the example below, I only want the NOTES header to be displayed if there are notes. If I put an {% empty %} inside the "f...
Swedenborgianism asked 2/7, 2013 at 20:24

10

Solved

Here's my custom filter: from django import template register = template.Library() @register.filter def replace(value, cherche, remplacement): return value.replace(cherche, remplacement) And, h...

3

Solved

I am trying to use django's built in 'default' filter using this code <title>{{ title|default :"nothing" }}</title> But it gives me the following exception django.template.b...

2

Solved

I used default_if_none as shown below: <input type="text" name='username' value="{{ value|default_if_none: '' }}"> But, I got the error below: django.template.exceptions...

2

I am new to Django and I am trying to create custom tags in django my custom tag file templatetag/custom_tag.py from django import template from model_file.models import my_Model register = temp...
Kuvasz asked 1/7, 2018 at 9:40

© 2022 - 2024 — McMap. All rights reserved.