django-templates

Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/

旧巷老猫 提交于 2019-12-02 10:04:26
I was following the django documentation and making a simple poll app. I have come across the following error : Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^polls/ ^admin/ The current URL, , didn't match any of these." settings.py ROOT_URLCONF = 'mysite.urls' mysite/mysite/urls.py 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),] mysite/polls/urls.py from django.conf.urls import url from . import views app_name= 'polls' urlpatterns=[

How to you pass a validation error to a template

落爺英雄遲暮 提交于 2019-12-02 09:15:53
问题 I have a IP validation rule such as : >>> validate_ipv46_address("1.1.1") Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/site-packages/django/core/validators.py", line 125, in validate_ipv46_address raise ValidationError(_('Enter a valid IPv4 or IPv6 address.'), code='invalid') ValidationError: [u'Enter a valid IPv4 or IPv6 address.'] And I have a form that is currently functioning like... class CacheCheck(forms.Form): type = forms

Jinja2 template super functions not rendered with django

此生再无相见时 提交于 2019-12-02 08:30:51
I have two very simple templates like index.html: <html> <head> </head> <body> {% block content %}hello{% endblock %} </body> </html> and details.html {% extends "index.html" %} {% block content %}{{ super() }} world{% endblock %} but when i render a view with details.html i get this error Could not parse the remainder: '()' from 'super()' do i need some import somewere? (templates are rendered properly until i use the super() function) Django 1.7 and earlier do not support Jinja natively. Unless you've done something to use Jinja, your templates should be in Django template language, and you

Use jQuery sortable with hidden table rows in django template

天大地大妈咪最大 提交于 2019-12-02 08:16:01
问题 I have a todo list that I display in a table element: <table class="table table-condensed> <thead> <tr class="table_header"> <th>Task Name</th> </tr> </thead> <tbody class="sortable"> {% for action in actions %} <tr class="item_row" id = "action_{{ action.id }}"> <td>{{ action }}</td> </tr> <tr class="detailed_row" id = "detail_{{ action.id }}"> <td>{{ action.notes }}</td> </tr> {% endfor %} </tbody> </table> I'm alternating between the action name and the action notes on each row of the

Dynamic name variable on django template

僤鯓⒐⒋嵵緔 提交于 2019-12-02 08:15:15
I'm having a problem with django. I have a dict with all my site texts for translations. For example: term = {"level_1": "Noob", "level_2": "Noob 2"} The problem is, how can I access this key on django template? I have img src="/images/level_{{player.level.id}}.jpg" title="{{term.level??????? }}" I tried: title="{{term.level{{player.level.id}}}} but of course this didn't work. Reinout van Rees Django's template language is (by design) pretty dumb/restricted. In his comment, Davind Wolever points at Accessing a dict by variable in Django templates? , where an answer suggests to make a custom

ajax with django forms

无人久伴 提交于 2019-12-02 07:53:43
can i add the ajax code with django? i have created a simple registraion form that have 5 fields . i wish to disply the each fields in different pages but in a single window . it means by using next button 5 pages want to disply in a single window. same time all content of each page i want add to my database. is this possible in django with ajax.. my codes are as follows : #view from django.shortcuts import render_to_response from registration.models import UserDetails from forms import UserForm from django import forms from django.template import RequestContext from django.http import

Django QuerySet returns nothing

一世执手 提交于 2019-12-02 07:29:54
I have a list of countries, they all have there own url www.example.com/al/ for example. There is a list of cities for every country but the object_list is empty My View: class CityOverview(generic.ListView): template_name = 'shisha/pages/country_index.html' model = City def get_queryset(self, *args, **kwargs): country_id = self.kwargs.get('country_id') return City.objects.filter(country__name=country_id) My Model: class Country(models.Model): COUNTRY_CHOICES = ( ('al', 'Albania'), ('ad', 'Andorra'), #etc. etc. ) name = models.CharField(max_length=255, choices=COUNTRY_CHOICES, default='nl')

Django TemplateDoesNotExist admin/login.html

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 07:24:05
I am working with django 1.4. And this error appeared: TemplateDoesNotExist at /admin/ admin/login.html I tried to reinstall django, but i did not work... Please Help! You can try to add the admin tempates path name to TEMPLATES['DIRS'] in your django settings.py The default TEMPLATES: 'DIRS': [os.path.join(BASE_DIR, 'templates')] change to if you are using Django project created by Pycharm: 'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'venv/lib/site-packages/django/contrib/admin/templates')] Assuming that you are trying to use the default Django admin, be sure that

google visualization-Click event on barchart isStacked: true

孤人 提交于 2019-12-02 06:50:41
问题 I'm trying to display the total value of a barchart where 'isStacked: true' on a <span> located on top of the chart when I click on a bar. My reference to explore the capability of google.visualization.events.addListener started here. When I click the a bar I recieved this error: Uncaught TypeError: Cannot read property 'row' of undefined or when I change the row to column Uncaught TypeError: Cannot read property 'column' of undefined Any pointers is really appreciated. Here's my django

Javascript syntax error in Django Template when variable value is missing

倾然丶 夕夏残阳落幕 提交于 2019-12-02 06:40:02
问题 I have a Django template with an AJAX menu (where clicking on different menu items reloads a part of the page). Each menu click invokes a Django view function through AJAX and returns some data to be shown on the page. I am loading all the JS required for all the menu items in the main page only (as I learnt that it is not a good idea for AJAX to return JS in a <div> and then use eval() to execute it). Since I am loading all the JS on the menu's main page only, the data obviously isn't there