Hello All,
This is the piece of code I am using to generate a template:
path = os.path.join(os.path.dirname(__file__), 'tag.html')
tag = cgi.escape(self.request.get("tag"))
query = DeliciousTags.all()
query.filter("tags =", tag)
query.order('creation_date')
results = query.fetch(20)
siteList = ''
if results :
siteList = resul...
Hi guys, i would like to know how show personalized error with get_object_or_404?, i dont want the normal http404 pages, i want to display a message with the result is none
thanks :)
...
Not sure if I've done something wrong but if I try to use a custom filter in an included template fragment I'm getting "invalid filter"
If I try the filter on the main template it works fine.
Is this a known limitation/bug?
...
Is there a way to get the current page URL and all its parameters in a Django template?
For example, a templatetag that would print full URL like /foo/bar?param=1&baz=2
...
Hey Guys,
I'm having problems displaying nested blocks in a template.
eg.
{% for category in categories %}
//code to display category info
{% products = products.object.filter(category = category) %}
{% for product in products%}
//code to display product info
{% endfor %}
{% ...
How can I change the output result from Django Admin Result List? I've been looking into the change_result_list.html template file but all I can find is :
{% for item in result %}{{ item }}{% endfor %}
Which will be outputting something like :
<tr>
<td>
<input type="checkbox" class="action-select" value="2" name="_selecte...
Hi,
I keep getting this error on my views. I can't work it out as the code is similar to the djangos tutorial just changing the objects name. Here is the code for my views.py:
from django.http import HttpResponse
from django.template import Context, loader
from django.shortcuts import render_to_response
from astonomyStuff....
I'm trying to use directeur's Django-sorting in a modelformset. My template code looks like this:
{% load sorting_tags %}
<table style="text-align: left;" border="1" cellpadding="5" cellspacing="0">
{% autosort formset.forms %}
{% for form in formset.forms %}
{% if forloop.first %}
<tr>
{% for field in form %}
...
I've found myself unsatisfied with Django's ability to render JSON data. If I use built in serializes then database foreign key relationships are not included in the data (only the keys). Also, it seems to be impossible to include custom data in the json feed that isn't part of the model being serialized.
As a test I implemented a tem...
I have an app that makes user of filtering certain things for users with different permissions.
Django 1.1 does for some reason not seem to recognize these.
I have a group called corporate and permissions are granted as needed.
now in my template I am render the following.
{% if perms.corporate %}
...show the following
{% ...
How can i pass QuerySet object in to template. And then Iterate through it in tempalte. If ican do it....?
Example
model=MyModel.object.all()
return render_to_response('template.html',{'model':model})
How it'll looks in template?
Can I show field of foreigne key object in this template?
...
Hi
I know about passing the context to templates, but I am bit confused with the given scenario, please help
class X:
id:
name:
status:
Class Main:
number1: object of X
number2: object of X
message: "Hello World!"
I get Object of Main which has two X objects but with different contexts.
I want to write one template for X and ...
What is wrong with the following code for file uploading.The request.FILES['file'] looks empty
Models:
from django.db import models
from django import forms
class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file = forms.FileField(label="Your file")
Views:
def index(request):
if request.m...
I'm programming a search on a model and I have a problem.
My model is almost like:
class Serials(models.Model):
id = models.AutoField(primary_key=True)
code = models.CharField("Code", max_length=50)
name = models.CharField("Name", max_length=2000)
and I have in the database tuples like these:
1 BOSTON The new Boston
...
Explain me please what this line doing:
<a href="{% url video.media.views.channel_browse slug=slug%}">Archie Channel</a>
Actually this:
{% url video.media.views.channel_browse slug=slug%}
I know that it give me URL, but what from, or how it is making this URL?
does this url depend from context? if it depend from context so which c...
To explain, I've taken a bare bones view from the tutorial of Django, and pointed it at an html page that I know works. When I do the following call:
return render_to_response('index.html', {'stuff': 'blah'})
The resulting page is terribly broken in the sense that a lot of the styles are totally lost. However when I view the page sour...
How can I measure time taken for template generation?
I know i can collect time Context.render() takes but can i do it unobtrusive way? Something like Page Stats Middleware do for Python and DB time... But split Python time to code/view time and template time?
...
Hi
I am new to Django, and want to do the following
I have a form that takes two inputs, processes and forwards the results to another page.
I want to display the results in the same page with form page included.
How can I do that in Django?
Thank you
...
Hi,
I am trying to access the contents of an array using forloop.counter0 in django templates but I can't get it working.
What I have is
{% for action in my_action_list %}
{{another_list.forloop.counter0}}
{% endfor %}
Where my_action_list is a list and another_list is also a list. I have tried doing this manually e.g. {{anothe...
I am currently trying to break a list of people (aprox 20 to 30 items) into a table with 4 columns. Here is my current code.
<table>
{% for person in people %}
{% cycle "<tr><td>" "<td>" "<td>" "<td>" %}
{{ person }}
{% cycle "</td>" "</td>" "</td>" "</td></tr>" %}
{% endfor %}
</table>
Obviously, this is pretty ugly, ...