django-templates

Django-like templates system for Java?

I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Is it exists? Update: The target is to have same templates files for different languages. File index.tpl {{head}} {{ var|escape }} {{body}} can be rendered from python (Django) code as well as from PHP, using Twig. I'm looking for Java ...

Django snippet with logic

Hi, is there a way to create a Django snippet that has logic? I think about something like contact template tag: {% contact_form %} with template: <form action="send_contact_form" method="POST">...</form> with logic: def send_contact_form(): ... I want to be able to use it anywhere in my projects. It should work only by sp...

Iterating dictionary indexes in django templates

Hi folks...I have a dictionary with embedded objects, which looks something like this: notes = { 2009: [<Note: Test note>, <Note: Another test note>], 2010: [<Note: Third test note>, <Note: Fourth test note>], } I'm trying to access each of the note objects inside a django template, and having a helluva time navigating to them...

Get list of Unique many-to-many records from a queryset

My models: class Order(models.Model): ordered_by = models.ForeignKey(User) reasons = models.ManyToManyField(Reason) class Reason(models.Model): description = models.CharField() Basically a user creates an order and gives reasons for that order. ie, john has two orders (one for pencils because he is out AND because he doesn...

Django 1.1 template question

Hi All, I'm a little stuck trying to get my head around a django template. I have 2 objects, a cluster and a node I would like a simple page that lists... [Cluster 1] [associated node 1] [associated node 2] [associated node 3] [Cluster 2] [associated node 4] [associated node 5] [associated node 6] I've been using Django for about ...

How to elegantly create a datatable with Django ?

Here's a common situation that I have and wish to avoid creating tedious loops and fiddling with html tables: I have a model Movie, which is has fkeys to Director and to Genre. How can I elegantly render a simple data table that has on one axis the different Directors, on another axis the different Genres, and inside each cell the coun...

How can I display multiple django modelformset forms in grouped fieldsets?

I have a problem with needing to provide multiple model backed forms on the same page. I understand how to do this with single forms, i.e. just create both the forms call them something different then use the appropriate names in the template. Now how exactly do you expand that solution to work with modelformsets? The wrinkle, of cour...

Is there a way to force a template to get translated to a certain language without passing RequestContext?

I'm rendering a template with a management command (something I need for producing documentation in my native language). So I've no request object, so no RequestContext. Is there a way I can force the template rendering process to lookup translation strings from a particular language other than English? ...

Django - problem with {% url facebook_xd_receiver %}

I'm using {% url facebook_xd_receiver %} in one of my HTML files. This works just fine when I run my project using the command python manage.py runserver But the same project stops running and gives me a "TemplateSyntaxError" at the line {% url facebook_xd_receiver %} Can anyone please tell me what could be the difference betwe...

Serve external template in Django

Hey, I want to do something like return render_to_response("http://docs.google.com/View?id=bla", args) and serve an external page with django arguments. Django doesn't like this (it looks for templates in very particular places). What's the easiest way make this work? Right now I'm thinking to use urllib to save the page to somewh...

KeyError with Django, Sociable app and accented characters?

I have a problem with my accented characters. Django admin saves my data without encoding to something like "&aacute;" Example: if im trying to use a word like "Canción", i would like it to save in this way: Canci&oacute;n, and not Canción. i have in my SETTING: DEFAULT_CHARSET = 'utf-8' i have in my mysql database: utf8_general_ci I...

How can I have multiple navigation paths with Django, like a simplifies wizard path and a full path?

Lets say I have an application with a structure such as: System set date set name set something Other set death ray target calibrate and I want to have "back" and "next" buttons on a page. The catch is, if you're going in via the "wizard", I want the nav path to be something like "set name" -> "set death ray target" -> "set ...

Django templates tag error

def _table_(request,id,has_permissions): dict = {} dict.update(get_newdata(request,rid)) return render_to_response('home/_display.html',context_instance=RequestContext(request,{'dict': dict, 'rid' : rid, 'has_permissions' : str(has_permissions)})) In templates the code is as, {% if has_permissions == "1" %} <input type="b...

Django models avoid duplicates

In models, class Getdata(models.Model): title = models.CharField(max_length=255) state = models.CharField(max_length=2, choices=STATE, default="0") name = models.ForeignKey(School) created_by = models.ForeignKey(profile) def __unicode__(self): return self.id() In templates <form> <input type="submit" s...

Passing variable urlname to url tag in django template

Hi All, What I'd like to do (for a recent changes 'widget' - not a django widget in this case) is pass a urlname into my template as a variable, then use it like so: {% url sitechangeobject.urlname %} Where urlname is a string containing a valid name for a url. Is this possible? The template keeps breaking saying it can't find sitechan...

Invoke Django template renderer in memory without any files from strings?

I have built a Macro language for my users that is based upon the Django template language. Users enter into UITextFields their template/macro snippets that can be rendered in the context of larger documents. So I have large multi-line string snippets of django template code that should be populated with variables that are also stored ...

How do you print out the exact text "{{text}}" in a Django template?

How do you print out "{{text}}" in a Django template? If I type it into a Django html template it gets interpreted as the variable text. I want the actual text: {{text}} To appear in the html output. ...

customizing basic existing Django apps that already have "nice looking" CSS/HTML templates?

I am looking for a basic Django application that "looks good" and has basic menus etc. that I could adapt for my own use. I am not doing any fancy processing of user input, but I do want to reuse an existing templates so that I don't have to worry about writing my own CSS/HTML to get clean, valid good looking webpages. Many of the Djan...

set user session in django

<?php session_start(); $_SESSION['username'] = "johndoe" // Must be already set ?> How to write equivalent code for the above in django ...

Django template doesn't render a Variable's method

Hello ! I am obviously victim of some dark magic... Here is a template that I render : context = Context({'my_cube': c}) template = Template( '{% load cube_templatetags %}' '{{ my_cube|inspect }} {{ my_cube.measure }}' ) Here is the implementation of the inspect filter : def inspect_object(obj): return obj.measure() He...