django-templates

Is there a better way to iterate over tuples in a (django) template in google-app-engine

Basically, what I'm trying to do is to render os.environ in a template in google app engine. I believe the technology is (or is adapted from) the Django template engine version 0.96 (but correct me if I'm wrong). I found this question suggesting that you could do: {{ for key, value in environ}} But when I try that, I get an error say...

Accessing previous array element in django template for loop.

Hi! 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 %} {% ifequal item.name[0] previous_item.name[0] %} {{ item.name[0] }} {% endifequal %} {{ item.name }}<br /> {% endforeach ...

tag url template django doesn't work

HI guys, I trying to implement the url template tag into my project. I have a button that allows the user to save the data he is seeing. So the url of this button is this: (2)url(r'^nameviews/download/$', 'my.path.is.this.to.download' name="load"), template: <a href="{% url load %}">Download</a> the url of the page that shows the ...

Django admin/doc/views/ all blank or broken

I'm trying to use Django's built-in admin docs feature to make writing templates easier. Supposedly if you go to /admin/docs/views you should get documentation for every view in your application. I see a list, but none of the links work: -) Any view listed that's related to my application just goes to a blank page with nothing but the n...

How do I get the built-in tag "url" to work?

Does anybody know how I can get built-in Django tag url to work in the wrapped template renderer in google-app-engine? It fails to create a "nice" url because it expects Django style url mappings, and since I'm using webapp.WSGIApplication I understand how it can be difficult for it to work. Basically I want to know if there is an altern...

How to display a list of objects containing many-to-many relations in Django template?

I have the following models: class Tag(models.Model): name = models.CharField(max_length=20) class Entry(models.Model): title = models.CharField(max_length=100) date = models.DateField() tags = models.ManyToManyField(Tag) In a view I create a list of Entry object and want to show the elements in the template: {% for entry...

JQuery post not passing variable

I'm trying to pass an image's src to a django view when a button is clicked. In my template, I have: $("#url_submit").click(function() { var film = "{{ filmname }}" var id = {{ id }} $.ajax({ url: "/db/gallery2/" + film + "/" + id + "/", data: {url: $('#large_thumbnail').attr('src')}, type: "POST" }); }); ...

How can I distinguish lists from strings in django templates

I'm developing a project on Google AppEngine, using Django templates, so I have to use tags like {{ aitem.Author }} to print content within my HTML template. Author, however, can either be a string or a list object, and I have no way to tell it in advance. When the Author is a list and I try to print it on my template, I get the ugly re...

I Can't get a dynamic radiobox value using Django

Hello everyone. I have a dynamic formulary that when a user types a query, it shows some radio box. And i get this error when i submit the form: MultiValueDictKeyError at /add_company/ "Key 'radioramo' not found in < QueryDict:... A sample of my javascript code: var elem = document.getElementById('div_field'); var radio_ramo ...

Summary tag for django templates

From time to time I have to write some simple summarized reports using Django. First I tried using Django ORM aggregates and interleaving results, but it can get a bit messy and I loose all the ORM laziness - just doesn't feels right. Lately I wrote a generic iterator class that can group/summarize a dataset. In the view it works like...

Dynamically choose which base template to extend in django

I have content that is going to be the exact same between the mobile and web site. The only thing i want to change is the base template. One base template for the mobile HTML, and one for the website HTML. One solution is to wrap the render_to_response and determine which HTML to render, but I'd still have two files. Is there a way I c...

Writing templates without using html for ruby on rails/django

I hate to explicitly use html/css to build pages. Is there a template language I can use to semantically and quickly describe the layout and content of the page so that later I can generate html and css from it? I'm planning to use this on a django site (but I guess if such solution already exists for RoR I can always adapt it). Thank...

django templates sysntax error

Is there any problem with the syntax in the following code,there is a error as Invalid block tag: 'else' {%ifequal chat_profile 1 %} {% extends "chatprofile/chat_profile1.html" %} {% else %} {% extends "chatprofile/chat_profile.html" %} {% endif %} ...

Change row colour in Django Admin List

I want to highlight rows (set the backgorund colour) in the Django Admin page (change_list.html) based on a field in the model called status. What is the best way to do this? I have 3 statuses. Open, Active, Closed. I'd like rows with open to be green, active to be orange and closed to be red. I've found documentation about changing...

GWT set variable values with Django templates.

I am using a tree control in my GWT application. The tree has different items based on the user logged in. One way to populate the tree would be to query the server from my GWT code to get a list of tree items. But since the items will always be shown would it not be better to include information regarding them in the page itself? I am l...

Django response query

What would be the correct statements for the below two.I want to send the base variable to my template which keeps varying but there will be an error if i send {'form': form,'msg' : msg} in the second statement return render_to_response('chatlist/newchat.html', context_instance=RequestContext(request,{'form': form,'msg' : msg}),extra_co...

jquery template tags conflict with Django template!

Today I'm trying to play with jquery-tmpl {{if}} & {{else}} statements. <script id="mission-dialog" type="text/x-jquery-tmpl"> <h3>${name}</h3> <p>${description}</p> <ul> {{each(i,cond) conditions.data}} <li> <img src="${cond.image}"/> <h4>${cond.name}</h4> <p class="status...

A Django seach form that I cannot make it work

Hello I have been recently working on Django search forms recently and have tired to edit one myself. Here is a search form that is supposed to find Clients. However When I type in a clients name, it does not display that client's name. So I am wondering What I am doing wrong. #model.py class Client(models.Model): comp...

How do you limit get_next_by_FOO inside a django view? code included

I have used get_next_by_FOO inside my view to display an absolute url for the following item within a set of records however when it gets to the end of the query set an error is raised. how do I stop my view from raising this error and instead just outputting some html letting me know that it has come to the end of the set? All help i...

Handling presentation logic in Django templates.

The description below is heavily simplified - it's only one part of a bigger problem that we are tackling but the innards can be safely left out for this question. Suppose we have the following models: - class Item(models.Model): name = models.CharField(max_length=150) value = models.DecimalField(max_digits=12,decimal_places=2)...