django-templates

django.template.base.TemplateSyntaxError: 'block' tag with name 'bottom_js' appears more than once

两盒软妹~` 提交于 2019-12-12 01:09:16
问题 I have this error : django.template.base.TemplateSyntaxError: 'block' tag with name 'bottom_js' appears more than once But I have no clue which template is at fault, how do I find this out ? Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/home/maazza/

Make django static tag globally available

旧城冷巷雨未停 提交于 2019-12-12 00:29:28
问题 I'm trying to make the Django 'static' tag available in all templates. I've tried this suggestion: from django.template.loader import add_to_builtins add_to_builtins('django.contrib.staticfiles') # I've tried each of these add_to_builtins('django.contrib.staticfiles.templatetags') add_to_builtins('django.contrib.staticfiles.templatetags.staticfiles') But keep getting the following error message: django.template.base.InvalidTemplateLibrary: Template library django.contrib.staticfiles does not

how to reference variable variable in jinja2 template

。_饼干妹妹 提交于 2019-12-12 00:22:01
问题 In one of my ansible roles I would like to set up a basic network/interfaces stanza, like this: auto eth1 ifaces eth1 inet dhcp dns-nameserver {{ ansible_eth1.ipv4.address }} dns-search maas I have variables, and I create the stanza with the jinja2 template: auto {{ iface }} ifaces {{ iface}} inet dhcp dns-nameserver {{ ansible_{{ iface }}.ipv4.address }} dns-search maas Can I reference a variable variable in a template? I also tried creating a variable in the ansible yaml, like nserver:

Django url template tag {% url %} error on django 1.4

冷暖自知 提交于 2019-12-11 23:15:23
问题 I made this many times and it worked, but not this time. I get this error when I try to use {% url path.to.view %} django's template tage: AttributeError at /login/ 'str' object has no attribute 'regex' urls.py (main) urlpatterns= patterns('', (r'', include('authenticate.urls')), ) urls.py (my app) urlpatterns= patterns('authenticate.views', url(r'^login/$','login'),) login.html {{ form }} {% url authenticate.views.login %} < --- Error comes here in the views: return render_to_response('login

How to use Django-ratings with bootstrap-rating-input

谁说我不能喝 提交于 2019-12-11 22:16:35
问题 Here goes another star rating question. I want to use bootstrap-rating-input to input rating value (1 to 5) and have django-ratings save the rating to the database. Although I'm a little green with javascript, I really want users to be able to vote using star rating instead of a number input form. Could you show me how to hook up these two apps to make them play nice with each other? What does the view and templates look like? And how do I configure the javascript to make the whole thing work

AJAX not working with Django App

妖精的绣舞 提交于 2019-12-11 22:13:53
问题 mysite/urls.py : from mysite import views url(r'^checkhandles/$', views.checkhandles, name='checkhandles'), mysite/views.py : def checkhandles(request, email): if request.is_ajax(): message = 'Yes, I am reachable!' else: message = 'No, I am not reachable!' return HttpResponse(message) mysite-ajax.js : on DOM-ready. $(document).on('blur', '#email', function(){ var $this = $( this ); var email = $this.val(); if (validateEmail(email) === true){ alert(email); var request = $.ajax({ url: "/mysite

get next after @login_required

元气小坏坏 提交于 2019-12-11 22:12:13
问题 I am currently unable to gain access to the next value from the @login_required redirection for some untold reason. I have attached my code for the login.html page and my project settings input name=next value='' whereas it should contain the value from {{ next }} which is shown in the debug dump as: GET data Variable Value u'next' [u'/accounts/profile/'] login.html : {% extends "base.html" %} {% block content %} {% if form.errors %} <p class="error"> Sorry, you have entered an incorrect

pass variable value store in dictionary to url parameter

时光总嘲笑我的痴心妄想 提交于 2019-12-11 20:36:42
问题 I pass dict addon_id_value_mapping = {'menu': '1', 'opening_hour': '2', 'books': '3', 'doctors': '4'} and addon_list = [{u'menu': [{u'price': 50, u'name': u'Momo', u'price_level': u'cheap'}, {u'price': 510, u'name': u'potato', u'price_level': u'expensive'}, {u'price': 100, u'name': u'Chowmein', u'price_level': u'expensive'}]}, {u'opening_hour': [{u'close': 17, u'open': 9, u'day': 0}, {u'close': 17, u'open': 9, u'day': 1}, {u'close': 16, u'open': 8, u'day': 2}]}] from view to django-template.

Is there any filter in Django to display asterisk(*) instead of text

女生的网名这么多〃 提交于 2019-12-11 20:11:20
问题 I am eager to know whether any filter is available for displaying all the text as * like this mytext = 'raja' {{ mytext|password }} should show **** How can we do this. plz help 回答1: Easy. Do this: {% for char in mytext %}*{% endfor %} That said, can I ask you where you are displaying the password? Usually passwords are not displayed on screen. If you want to display it in a form you can use a PasswordInput widget. As @Ars said it is a bad idea to reveal the length of the password. You might

Can we format as to how the Model Form displays in Django on template

喜你入骨 提交于 2019-12-11 19:44:58
问题 So I am using the django user model (from django.contrib.auth.models import User) and created a Model Form by using the ModelForm (from django.forms import ModelForm). When i display it on the template it shows up on the select boxes as usernames. i want to display it is first_name and last_name. Thisis the code I am using for form in HTML <form class="form-horizontal" method="post" role="form"> {% csrf_token %} <fieldset> <legend>{{ title }}</legend> {% for field in form %} {% if field