django-templates

List products by category in Django template

What's the best way to generate HTML which has a heading for each Category, and Products under that category in a Django template? I toyed with the idea of having a passing a dictionary, or an ordered list... ...

Can't use Django's get_absolute_url in dictionary of dictionaries?

I'm having some trouble using get_absolute_url in a template. It seems to work fine if I just pass in one of my store objects and say {{ store.get_absolute_url }}, but if I have to iterate through a dictionary of stores and then use the get_absolute_url function, it returns nothing. Exactly what I'm doing is below: class Store(Ethical...

How can I optimize my database queries using my actual django model ?

I can't post image because I'm new so here's a link of what I want. So, I have the model on the left and I want the view on the right. As of now, I'm looping over every thread I'm interested in. Template code: {% for thread in threadlist %} {% for post in thread.postlist %} ... Model code: class Thread (models.Model): ... def po...

What is the fastest template system for Python?

Jinja2 and Mako are both apparently pretty fast. How do these compare to (the less featured but probably good enough for what I'm doing) string.Template ? ...

django+ send email in html with django-registration

Hi guys, im using django-registration, all is fine, the confirmation email was sending in plain text, but know im fixed and is sending in html, but i have a litter problem... the html code is showing: <a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/"&gt;http://www. example.com/accounts/activate...

how to make a page in django

Hello , I have two models , class A(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=200) type = models.CHarFIeld(max_length=200) .. .. .. class B(models.Model): a= models.ForeignKey(A) state = models.CharField(max_length=200) now when i am seeing the page of class A i...

How do I use Django's template extends variable?

The django template doc mentions the following for extending templates: {% extends variable %} Where do I define the variable? Is it from the views.py? ...

django template system, calling a function inside a model

hello, I want to call a function from my model at a template such as: class ChannelStatus(models.Model): .............................. .............................. def get_related_deltas(self,epk): mystring = "" if not self.get_error_code_delta(epk): return mystring else: for i in self.get_listof_ou...

Django templates "ifless", "ifgreater"

Hi, is there anything built-in in Django templates that will allow me to compare two values? Similar to ifequal. If not - what is the best solution for this? ...

Django regroup tag problem

Hello All, I have a custom filter user_tz which takes user as an argument. It works fine everywhere, but when I tried to use this filter in the regroup tag it fails saying that user does not exist. The code: {% regroup proj_messages.object_list by created_on|user_tz:user as proj_message_list %} This is the error I am getting: Caught ...

django newline problem

hi all, i am using django for development. retriving some text with newline from database. but when i render it to template and print in template do not show newline char. what is the porblem ?? plz any one , if can help me BR// Nazmul ...

How to create translation to "timesince" value ? (template tag)

I review docs but I am lost... some problem with it: {% load i18n %} {% blocktrans %} {{ wpis.entry.lastChangeDate|timesince }} {% endblocktrans %} Raise: `KeyError: u'wpis.entry.lastChangeDate | timesince'` Of course, without blocktrans all works fine. So, what is simples way to translate few words? (I am interesting polish lang...

Display thousands position

I'd like to display only the numbers that lie in the thousands position for a value i.e. 193000 will be displayed as 193 and so on. How do I achieve this, maybe at the template level? ...

Tell if a Django Field is required from template

I'm rendering a form. I would like to put a mark next to all the fields that must be filled in. Simple stuff usually... but I've no idea how to access that information! {% if field.required %}REQUIRED!!{% endif %} doesn't bring any love... ...

Django admin, custom view error : invalid literal for int() with base 10

I'm trying to make a custom view in Django admin. I'm reading from this site, Simple Django Admin Preview, but I have a problem: ValueError: invalid literal for int() with base 10: '13/preview' Here is my url.py: url(r'^admin/diligencias/diligencia/(?P<object_id>\d+)/preview/$','preview'), Here is my view.py: @staff_member_require...

Django preview, TypeError: 'str' object is not callable

I'm trying to make a Preview function. I'm reading this blog, Django Admin Preview, but now I have the following error and I don't know what it means. Traceback (most recent call last): File "/home/user/webapps/django/lib/python2.5/django/core/handlers/base.py", line 92, in get_response response = callback(request, *cal...

Django template, how to make a dropdown box with the predefined value selected?

Hi all, I am trying to create a drop down list box with the selected value equal to a value passed from the template values, but with no success. Can anyone take a look and show me what I am doing wrong. <select name="movie"> {% for movie in movies %} {% ifequal movie.id selected_movie.id %} <option value="{{movie.k...

Django and Openx ??

Hi guys, good morning :), somebody know how use Openx (php app) with Django?, i need to use openx or similar soft for ads. Thanks :) ...

django templates: include and extends

I would like to provide the same content inside 2 different base files. So I'm trying to do this: page1.html: {% extends "base1.html" %} {% include "commondata.html" %} page2.html: {% extends "base2.html" %} {% include "commondata.html" %} The problem is that I can't seem to use both extends and include. Is there some way to d...

Associating two database tables which have ForeignKey relation in models.py in django templates

Hi all, I have problem about django template-db query relationship. For example, I created two tables in db (e.g. Menu & Submenu). Submenu, as you can guess, has a ForeignKey relationship with Menu. On the template side how can Ido db-query according to this relationship. I want to have a link for Menu such as: {% for menu in menu_li...