django-templates

Sporadic TemplateDoesNotExist errors in django

I have a django (v1.1.1) on a server running Python 2.4. On my localhost/development computer the site works perfect. When I uploaded the files to the production server, it seemed to work fine, but after a page refresh I am receiving random TemplateDoesNotExist errors. In the trace report I looked at the TEMPLATE_DIRS variable to make s...

Google Maps not working in Django template on App Engine development server

When I add this script to a plain HTML file's HEAD section <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt; and I run this script on the body onload, function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, cent...

Traversing multiple lists in django template in same for loop

I want to travere multiple lists within a django template in the same for loop. How do i do it? some thinking link this - {% for item1, item2, item3 in list1, list2 list3 %} {{ item1 }}, {{ item2 }}, {{ item3 }} {% endfor %} Is something like this possible? ...

Math comparison operating in Django templates

i want to compare do simple math in django template like {% forloop.counter > 5 %} {% endfor %} how do i achieve this? ...

Math comparison operating in Django .96 templates

i want to compare do simple math in django template like {% forloop.counter > 5 %} {% endfor %} how do i achieve this? ...

Mathematical Operations on Django Annotations.

I have a Django model that defines a TimeSlot. Each TimeSlot can hold a certain number of users (TimeSlot.spots). Each TimeSlot also has a certain number of users already held in it (a many to many field, TimeSlot.participants. When I pass to the template that displays the available TimeSlots to the user, I annotate with TimeSlot.objec...

Django Many to Many Record only display last record

Dear All, I have problem with display record from django . multi devices have multi services and others many-to-many model models.py class Service(models.Model): service_name = models.CharField(max_length=25) service_port = models.IntegerField(max_length=6) class Devices(models.Model): hostname = models.CharField(max...

Django: How to force translation into a given language inside a template ?

In a Django template, I need to transanlate some strings to a specific language (different from current one). I would need something like this: {% tans_to "de" "my string to translate" %} or {% blocktrans_to "de" %}my bloc to translate {% endblocktrans_to %} to force translation to German. I know I can call the following code in a v...

Django Templates - Printing Comma-separated ManyToManyField, sorting results list into dict?

Hi, I have a Django project for managing a list of journal articles. The main model is Article. This has various fields to store things like title of the article, publication date, subject, as well as list of companies mentioned in the article. (company is it's own model). I want a template that prints out a list of the articles, sorte...

How do I print some python function output to console (for debugging purposes, while using manage.py runserver) from within a django template

I am working on a custom Django form field and accompanying widget. While rendering the template, i would like to inspect the form.field as a python object. How do I do that, because anything in a Django template outside of template tags and filters is rendered as text. ...

Django: Create a variable in template

I have a list of values I want to display in a template of django. The list is more or less like this: 199801 string1 199802 string2 199904 string3 200003 string4 200011 string5 where the first column is a date in the form YYYYMM and the second is a generic string the list is ordered by date desc What I want to create is a list of ...

django to return json format data to prototype ajax

Hi all, is there a way i can pass json format data through django HttpResponse. I am trying to call the view through prototype ajax and return json format data. Thanks ...

Django: Get custom tag output inside a view

Hello! I have a very specific problem. I wrote a special template tag to display some peace of HTML code based on some calculations. Tag call looks like this: {% chord 'A' %} And the output generated is <div class="chord">A <audio src="/media/chords/A/A.mp3" controls>Not supported</audio></div> Everything works fine, but I came ...

Django Admin Templating

Hi, I am learning django and building my own project. I want to change the admin section to my own interface, I have added sub-directory to the templates names "admin".And started change the base.html The problems are- I want to add my own css file, how I can do it?My css file is located on my MEDIA_ROOT directory.How I can do that? ...

Submitting form without redirects in Django

In my main page I have included a template with form for adding emails to newsletter. I'd like this form to add new emails without redirecting anywhere. How I can achieve that ? Here is my code, when I was using separate page for this : views : def newsletter_add(request): if request.POST: f = NewsletterForm(request.POST) ...

How to make a Template extend another one?

I've got some templates which I'm building from some data I've got stored in my DB: my_template = Template(string_data) Now I want that template to extend another one (also stored as text in the DB). How can I do that? Looking for something like: my_template.base = other_template Or whatever the syntax is. Can't find documentation ...

how to pass common dictionary data to every pages in django

I have a common data {the logged-in user's message number) to display on every page. I can simply pass to template as dict={'messagenumber':5} return render_to_response('template.html',dict,context_instance=RequestContext(request)) But it looks tedious if i have this dict data pass to very page. Is there an easier way to pass common d...

Return a list of lists to template and render it

In my project I deal with various sorts of events taking places in different cities. I'd like to present list of events per city in a template, but how to do that ? My view now looks like this : def events_by_state(request, state): cities = City.objects.filter(state_slug=state) For each city I'd like do a query : for c in cities...

Sending HTML email in django

In my project I've added a newsletter feed. But when trying to send emails with this function : def send(request): template_html = 'static/newsletter.html' template_text = 'static/newsletter.txt' newsletters = Newsletter.objects.filter(sent=False) subject = _(u"Newsletter") adr = NewsletterEmails.objects.all() fo...

Creating an unlimited forum hierarchy in Django.

Hello, I'm trying to design models for a forum I wish to create in Django. So far I have: class Forum(models.Model): name = models.CharField(max_length=255) slug = models.SlugField(max_length=150) description = models.TextField() def __unicode__(self): return self.name class SubForum(models.Model): paren...