django-templates

Getting my head around django model relationships, forms, and jquery

Hey all, I'm fairly new to both django and jquery, but have a couple years of general oo programming experience (mainly flash/flex/cf), and I'm trying to figure out the best way to implement a form for a sports tournament that manages a few model relationships and uses some simple jquery to improve usability. My models look like this: ...

Django: which context belongs to which template

Hi all, I'm on the verge of testing attributes in response.context with django's own test client (in django.test.client). I get back 5 response.context's. As it seems one for each template part, because when I remove a nested template part (e.g: {% include "sometemplate.html" %}) from the base template the amount of returned context's ...

Django: RequestContext issues?

I'm new to Django and Python. When I move my code from my local dev box to my site on Webfaction it seems to break my code. If I then remove (context_instance=RequestContext(request)) from my main application views.py it seems to fix the problem. If later I put the line back in it works fine. return render_to_response('template.html',...

Django: iterating over the options in a custom select field

Hi, I'm using a custom MM/YY field and widget based on this example. I want to iterate over the individual month and year options defined in the widget class in order to apply "selected='selected'" to the MM/YY value that corresponds with the MM/YY value stored in the database. This seems like such a messy way of doing this, so if you...

Multiple level template inheritance in Jinja2?

I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you can't do more than on...

django query question

Hello Assume I have such simple model: class Foo(models.Model): name = models.CharField(max_length=25) b_date = models.DateField() Now assume that my query result from Foo.objects.all() , I retrieve something like this: [ {'name': 'zed', 'b_date': '2009-12-23'}, {'name': 'amy', 'b_date': '2009-12-6'}, {'name': 'j...

Django template question

Hello How can I achieve this using the Django template system: Say I have 2 variable passed to the template system: days=[1,2,3,4,5] items=[ {name:"apple,day:3},{name:"orange,day:5} ] I want to have such output as a table: 1 2 3 4 5 apple n n y n n orange n n n n y As you can notice, gi...

django __unicode__() - how can i call this method in a template

Hi, I defined a unicode() method in my Contact model. def __unicode__(self): return u'%s %s' % (self.first_name, self.last_name) Now I want to show the return value of the unicode() method in a template. But all that i try fails. {{ object.unicode }} or {{ object.unicode() }} or {{ object.__unicode__ }} or {{ obj...

django change form field in .html template output

Hi, I create a form based on a model , like seen below: class ContactSelectionForm(forms.ModelForm): contacts = ManyToManyByLetter(Contact, field_name="first_name") class Meta: model = ContactSelection exclude = ('created_by',) When I process this view I see at the .html output a field labeled with "Contact"...

Looking for a resource which provides django templates

Hello all, I'm pretty handy with django and python but I'm terrible at the "visual" aspect of the web-design. Even after quite a bit of google-ing I haven't been able to find any sort of resource that has download-able templates complete with css, images, etc. that could be used to set up a basic website easily. I'm looking for example...

Safely rendering user provided django templates

So as per a previous question of mine I've decided to start a website which allows django designers to upload templates and css files. I'll provide a well defined set of context inputs and objects and then render the templates that the users provided. This will hopefully give newbies a large set of examples to work from and designers a...

Django Nested Relations

I'm not sure if I just can't concentrate or what, but I feel like this should be easy to do. I have 2 models, one that references the other as a simple foreign key relation (one-to-many) now in the template I want to display this relation as a nested unordered lists. ...

Problem with django's url template tag (and reverse() function)

I have the following view function in activities.views: def activity_thumbnail(request, id): pass I'm trying to get the URL for that view in one of my templates. When I try the following: {% url activities.views.activity_thumbnail latest_activity.id %} I get the following error: Caught an exception while rendering: Reverse ...

Indeterminite number of apps/widgets in Django template

Hi, I'm working on a site that will have a bunch of pages with an indeterminate amount of "apps" on each page. Something like a calendar app, and a random picture app, or whatever, each in a neat little box. While it's possible to write a template with a bunch of if tags that include other templates, this is a bit of a hassle. I'd like ...

POST request returns back to admin index page with "You don't have permissions to edit anything"

I am overriding the admin index.html template by adding at the end: <h1>Exporting and Validating Users</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} {% if export_message %} <p><strong>{{export_message}}</strong></p> {% endif %} <table> <tr> <td> <form action=...

Custom Django template tag to look up a string username and return it as a user object.

I use some third-party template tags in my Django Application (maintained elsewhere) that return a username as a string I can access in my templates like this. {% for user in gr.user.foll.list %} {{user}} Trouble is because {{user}} is returned as a string - I need to convert into a Django User Object, if it exists in the Django DB,...

Get specific fields from a formset

For the documentation, I'm able to display a formset as below <table> {{ formset }} </table> However, what if I want to format the layout manually? Like how it's done for ModelForms? How can I achieve this? ...

Django: get parent objects matching condition on child

Couldn't think of a more appropriate question title, but I'm looking for some advice on how to implement the following requirement: I have a Project class, which may contain Task objects. Tasks have an assignee. In my Django template, I'd like to render a 'tree' of projects and tasks for a given user, showing only those projects that ha...

django template

I am overwriting an inline template - in my template I used: {% for line in fieldset %} {% for field in line %} <td class="original {{ field.field.name }}"> <div name="foobar_a"> {% ifequal field.field.name "rule_type" %} {% ifequal field.field "2" %} fine {% endifequal %} {% endifequal %} ...

How to modify a template of a reusable app in Django?

For example, let's say I want to modify the breadcrumbs block of the admin/change_list.html template in the Django admin. If I try to override this template like this: {% extends "admin/change_list.html" %} {% block breadcrumbs %} ... my changes ... {% endblock %} then Django goes into an infinite recursion when trying to load my over...