django-templates

Overriding templates in Django

I am trying to override a template that has a block that loads and displays comments. Like this... I have the Comments in the installed apps here. base.html <html> <body> {% block show_comments %} ...Do some stuff to show comments. {% endblock show_comments %} </body> </html> Now, I wanna extend this "base.html" template in another ...

Username not being displayed correctly

I have a field for addedBy in one of my classes. I've set up a count for this field as below: user_count = Issues.objects.values('addedBy').annotate(count=Count('id')) Then in my template I'm accessing the variable as {% if user_count %} <div class="menutitle"><strong>{% trans "Added By" %}</strong></div> {% for item in us...

Auto-arrange <li> elements into equal columns

I have several values I'm rendering as <li> elements on my template and I want to further this by having them arranged into equal (or near-equal columns) automatically in the template. How can I achieve this? So far I'm rendering all the values as <ul> {% for feature in features %} <li>{{ feature }}</li> {% endfor %} </ul>...

Load custom template tag from another application?

Is this possible in any way? My project folder structure looks like this: my_project: app1: templatetags: my_tags1.py (contains simple tags and inclusion tags) app2: templatetags: my_tags2.py (contains some simple tags) templates: app1: index.html app2: index.html The...

Django while loop

Hi, I wonder if there's any way to do a while loop in django (I think that's what I'm after)? What I'm trying to do is a nestled ul/li list. The list is generated by a for loop in a for loop. But since some elements in the second for loop has more child's I want to iterate or them to and so on until all child nodes are iterated out. O...

Iterating through two lists in DJango temlates

I want to do the below list iteration in django templates: foo = ['foo', 'bar']; moo = ['moo', 'loo']; for (a, b) in zip(foo, moo): print a, b django code: {%for a, b in zip(foo, moo)%} {{a}} {{b}} {%endfor%} I get the below error when I try this: File "/base/python_lib/versions/third_party/django-0.96/djang...

Django filtering links and long words at once

Is there a method one can filter output string in two ways at once: divide long words into parts (but not like in truncate where the truncated part is not visible, but it should be separated with let's say empty space) change text links into clickable links Let's say we have string like this : "IamareallylongwordandsoIneedToBeSplit ...

stop django from taking out javascript/frames?

Very newbie question, but please be gentle with me. Our site uses Django CMS and we're trying to insert some javascript into particular stories, but it appears Django is stripping out any javascript or iframes we put in there as soon as we save the story. How do we allow javascript to be used in stories? Is it being deliberately excluded...

How do I overrride fieldset.html template so that I can pass more arguments

I am overriding the admin fieldset.html template? I need to access the model. I have a table called domain and I need to query the database (Domain.objects.all) get a list of all the domains and pass it to the template. How/where would I do it especially with respect to admin interface. Thanks ...

Putting a block inside another in Django

I have a Django template that I want to extend in multiple places. In some the div must be inside a form, and in others it must not be. To do this I put a block above and below the div so I could add and in them respectively. Desired: <form> <div class="my_div"> {% block div_content %} ... {% endblock %} </div> </form> Te...

Django App for Academic Journal?

I'm looking a Django app I'm looking for an app that that allows for management and integration of footnotes for articles just wondering if anyone had seen something around... ...

Django admin site auto populate combo box based on input

hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True...

Problem with messages framework in Django 1.2

Hello! I'm running Django 1.2 beta and trying out the new feature: message framework. http://docs.djangoproject.com/en/dev/ref/contrib/messages/ Everything seems to work, but when I try to output the messages, I get nothing. Seems that messages variable is empty. I double checked all the settings, they seem to be just like in the manu...

How to display a form filed with size and maxlength attributes in Django?

I have a model form that contains a DecimalField() with max_digits set to 5. How do I display this field this way: <input type"text" size="5" maxlength="5" /> ...

Check if a template tag is loaded in Django

Is there a way to check if a template tag exists before using the template tag? In other words, I would like to be able to do something like this: {% load my_custom_tags %} ... {% ifloaded my_custom_tags %} {% some_custom_tag %} {% endifloaded %} ...

Load django template from the database

Hello, Im trying to render a django template from a database outside of djangos normal request-response structure. But it appears to be non-trivial due to the way django templates are compiled. I want to do something like this: >>> s = Template.objects.get(pk = 123).content >>> some_method_to_render(s, {'a' : 123, 'b' : 456}) >>> ... t...

Django template call function

I'm passing to Django's template a function, which returns me some records. I want to call this function and iterate over it's result. {% for item in my_func(10) %} That doesn't work. I've tried to set fuction's return value to a variable and iterate over variable, but there seems to be no way to set variable in Django template. ...

Django - provide additional information in template

Hi all, I am building an app to learn Django and have started with a Contact system that currently stores Contacts and Addresses. C's are a many to many relationship with A's, but rather than use Django's models.ManyToManyField() I've created my own link-table providing additional information about the link, such as what the address typ...

Django parallel arrays in a template

I have 2 arrays that I would like to render in a template, one is the data to be output, the other is a formset for deleting items. since it seems django does not support boolean operators in the template tag, I have tried packaging the items, but they return the first item and the first form in 2 rows only. How does one package such i...

Looping to provide multiple lines in linechart (django-googlecharts)

Hi, I'm trying to generate some charts using django-googlecharts. This works fine for rather static data but in one case I would like to render a different number of lines, based on a variable. I tried this: {% chart %} {% for line in line_data %} {% chart-data line %} {% endfor %} {% chart-size "390x200" %} {% chart-...