django-templates

Django-compressor and template inheritance

♀尐吖头ヾ 提交于 2019-12-31 22:38:11
问题 I'm using the django-compressor app in Django 1.2.3 to minify and merge a number of included CSS and JS files. In a base template, I have {% load compress %} {% compress js %} {% block js %} <script type="text/javascript" src="/site_media/js/jquery.query-2.1.7.js"> {% endblock %} and in a child, {% block js %} {{block.super}} <script type="text/javascript" src="/site_media/js/jquery.validate.min.js"> {% endblock %} When the templates render, the first script tag is correctly minified, but the

Template does not exist

时间秒杀一切 提交于 2019-12-31 19:00:01
问题 I am new to Django. I made a folder named templates in my project and "base.html" inside it, it works fine. But when I make new folder inside templates welcome and then "home.html" and I write some lines of code in my views.py file as from django.shortcuts import render_to_response def hello(request): return render_to_response('welcome/home.html') and settings.py includes # Django settings for Telecom project. DEBUG = True TEMPLATE_DEBUG = DEBUG import os #BASE_DIR = os.path.dirname(os.path

Whats the correct way to use and refer to a slugfield in a django 1.3

a 夏天 提交于 2019-12-31 17:25:53
问题 Whats the correct way to use and refer to a slugfield in a django 1.3 for example the following code should link via slug to a generic view however the NoReverseMatch error is received. Caught NoReverseMatch while rendering: Reverse for 'single_post' with arguments '('', u'post-2')' and keyword arguments '{}' not found. From my understanding this saying that the error lies in the template however being a newbie and having tried many different variations on {% url single_post slug=post.slug %}

Whats the correct way to use and refer to a slugfield in a django 1.3

不问归期 提交于 2019-12-31 17:25:34
问题 Whats the correct way to use and refer to a slugfield in a django 1.3 for example the following code should link via slug to a generic view however the NoReverseMatch error is received. Caught NoReverseMatch while rendering: Reverse for 'single_post' with arguments '('', u'post-2')' and keyword arguments '{}' not found. From my understanding this saying that the error lies in the template however being a newbie and having tried many different variations on {% url single_post slug=post.slug %}

Python Social Auth Django template example

那年仲夏 提交于 2019-12-31 08:52:28
问题 Does someone has an open example using Python Social Auth with Django in templates? I took a look in their Github repo, and in the django exmaple, there is nothing about how to deal with it in templates (e.g. doing login, logout, etc). 回答1: Let’s say you followed Python Social Auth configuration guidelines at http://psa.matiasaguirre.net/docs/configuration/django.html and you want using facebook login. Your backend settings in settings.py should look: AUTHENTICATION_BACKENDS = ( 'social

Python Social Auth Django template example

孤街醉人 提交于 2019-12-31 08:52:26
问题 Does someone has an open example using Python Social Auth with Django in templates? I took a look in their Github repo, and in the django exmaple, there is nothing about how to deal with it in templates (e.g. doing login, logout, etc). 回答1: Let’s say you followed Python Social Auth configuration guidelines at http://psa.matiasaguirre.net/docs/configuration/django.html and you want using facebook login. Your backend settings in settings.py should look: AUTHENTICATION_BACKENDS = ( 'social

Django - rendering many templates using templatetags is very slow

空扰寡人 提交于 2019-12-31 08:48:08
问题 Say, I have a page with a photo gallery. Each thumbnail has e.g. a photo, country, author and so on. I render these items/widgets using template tags (which load specified templates) - it goes that way because of DRY (I use these items/widgets separately in different places on the page). And it is very slow. I have performed some profiling using django-debug-toolbar: SQL Queries: default 84.81 ms (147 queries) But: Total CPU time: 5768.360 msec Which is too long to wait. After some analysis

how to create counter loop in django template?

折月煮酒 提交于 2019-12-31 07:41:35
问题 can any tell me how can I write below code of c in django for(c=0; c<5; c++) //do something i had tried below code but it gives me an error {% for(c=0; c<5; c++)%} <div class="tab-content"> <h1 class="tab" title="title for page 1">Page 1</h1> <p>This is the content of tab 1 on container 1</p> </div> {% endfor %} 回答1: When you render your template, you may pass range render_to_response('template_x.html', {'range5': range(5)}) And in html template, probably like this {% for i in range5 %} <div

how to create counter loop in django template?

为君一笑 提交于 2019-12-31 07:41:30
问题 can any tell me how can I write below code of c in django for(c=0; c<5; c++) //do something i had tried below code but it gives me an error {% for(c=0; c<5; c++)%} <div class="tab-content"> <h1 class="tab" title="title for page 1">Page 1</h1> <p>This is the content of tab 1 on container 1</p> </div> {% endfor %} 回答1: When you render your template, you may pass range render_to_response('template_x.html', {'range5': range(5)}) And in html template, probably like this {% for i in range5 %} <div

How to render two form fields as one field in Django forms?

淺唱寂寞╮ 提交于 2019-12-31 05:58:08
问题 I'm working on Django application where I need to render a form differently. The form contains multiple fields related to a person. 1. Firstname 2. Lastname 3. Email 4. Address 5. City 6. Country 7. Phone 8. Pincode There are two flows in my application. In the first flow I can render all the form fields and save them when the user enters some data and submit. But in the second flow, I need to display only three fields as below. 1. Name - *Combination of Firstname and Lastname* 2. Email 3.