I am having trouble doing a reverse URL lookup for Django-generated feeds.
I have the following setup in urls.py:
feeds = {
'latest': LatestEntries,
}
urlpatterns = patterns('',
# ...
# enable feeds (RSS)
url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}, name='feeds_vie...
In Rails ERB, you can suppress newlines by adding a trailing hyphen to tags:
<ul>
<% for @item in @items -%>
<li><%= @item %></li>
<% end -%>
</ul>
becomes:
<ul>
<li>apple</li>
<li>banana</li>
<li>cacao</li>
</ul>
Is there a way to do this in Django? (Disclosure: I'm generating a csv file with Django)
Edit: Cla...
I need to display a piece of HTML only if a variable value appears in a list. I know that Django 1.2 has an 'in' operator. But I am working on a Google App Engine app. Is there a workaround I can use?
...
I want to give default value to a textarea. The code is something like this:
<textarea>{{userSetting.list | join:"NEWLINE"}}</textarea>
where userSetting.list is a string list, each item of whom is expected to show in one line.
textarea takes the content between the tags as the default value, preserving its line breaks and not interp...
A form will be spitting out an unknown number of questions to be answered. each question contains a prompt, a value field, and a unit field. The form is built at runtime in the formclass's init method.
edit: each questions receives a unique prompt to be used as a label, as well as a unique list of units for the select element.
this s...
I publish discount offers for my city. Offer models are passed to template ( ~15 offers per page). Every offer has lot of items(every item has FK to it's offer), thus i have to make huge number of DB request from template.
{% for item in offer.1 %}
{{item.descr}}
...
I have an inlineformset with a custom Modelform. So it looks something like this:
MyInlineFormSet = inlineformset_factory(MyMainModel, MyInlineModel, form=MyCustomInlineModelForm)
I am rendering this inlineformset manually in a template so that I have more control over widgets and javascript. So I go in a loop like {% for form in myfo...
I am using django to build an app that is slightly heavy on functionality. Consequently my templates are a bit heavy (nested loops, if conditions etc). I am noticing that 70% to 80% of time is spent in render_to_response step of my views.
I haven't found anything indicating performance issues around template engine in django on google. ...
I am learning Django and got it to work with wsgi. I'm following the tutorial here:
http://docs.djangoproject.com/en/1.1/intro/tutorial01/
My question is: how can I customize the look and feel of Django? Is there a repository of templates that "look good", kind of like there are for Wordpress, that I can start from? I find the tuto...
I have a webapp that lists all of my artists, albums and songs when the appropriate link is clicked. I make extensive use of generic views (object_list/detail) and named urls but I am coming across an annoyance. I have three templates that pretty much output the exact same html that look just like this:
{% extends "base.html" %}
{% bl...
Hello everyone,
I have a string that I want passed via the "linebreaks" filter.
{% trans "my string"|linebreaks %}
Doesn't work.
Is there another way ?
...
Hi Guys,
Currently a bit stuck, wondering if anyone can assist. I am using django-adminfiles. Which is a neat little application. I want to use it to insert images into posts/articles/pages for a site i am building.
How django-adminfiles works is it inserts a placeholder i.e <<< ImageFile >>> and this gets rendered using a django temp...
Hi. Can someone please help me figure out a way to achieve the following (see snippets below) in Django templates? I know that you cannot use more than one extends, but I am new to django and I do not know the proper syntax for something like this. I want to be able to do this so that I can use my nested div layout for css reasons wit...
Suppose my template has in it something like {% block subject %}my subject{% endblock %} and I load this template with tmpl = loader.get_template('mytemplate.html'), how can I extract "my subject"?
...
I have a template which is just a simple list of objects, and I would like to show the current user's rating for each object next to that object. Here are the relevant models:
class Problem(models.Model):
question = models.TextField()
answer = models.TextField()
topic = models.ForeignKey(Topic)
class Attempt(models.Model):
...
I have been using the Django Messaging Framework to display messages to a user in the template.
I am outputting them to the template like this:
<ul>
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
This outputs all the messages, errors, ...
Hi Guys,
Wondering if it's possible to change a value returned from a queryset before sending it off to the template.
Say for example you have a bunch of records
Date | Time | Description
10/05/2010 | 13:30 | Testing...
etc...
However, based on the day of the week the time may change. However this is static. For example on a monday ...
I would like to have AppEngine render an html page that auto scrolls to an html anchor point. I'm not sure how and where to put that type of instruction.
template_values = {
'foo' : 'foo',
'bar': 'bar',
'anchor' : '#MyPageAnchor' # ?? Something like this...
}
path = os.path.join(os.path.dirname(__file__), file...
I have a template that shows a filter form and below it a list of the result records. I bind the form to the request so that the filter form sets itself to the options the user submitted when the results are returned.
I also use pagination. Using the code in the pagination documentation means that when the user clicks for the next page...
I want to create a list of records with checkboxes on the left side....kinda like the inbox in Gmail. Then if a user selects some or all of these checkboxes, then the selected record(s) can be updated (only one field will be updated BTW), possibly by clicking a button.
I'm stuck on how to do this though....ideas?
Display Code
{% fo...