django-templates

Django: where is the code that prints the "+" icon close to a foreign key?

I cannot find which part of code print the "+" that is close to every foreign key field. In fieldset.html there is only the call to {{ field.field }}, but in the file django/forms/widgets.py the code that prints the select, doesn't contain that code, so I suppose that there is a piece of code that manage the foreign key: where is it? ...

How do I access a python list from a django templatetag?

I have created a templatetag that loads a yaml document into a python list. In my template I have {% get_content_set %}, this dumps the raw list data. What I want to be able to do is something like {% for items in get_content_list %} <h2>{{items.title}}</h2> {% endfor %}` ...

Django Newbie ManyToManyField Template Question

Hello. I have a Django model with a ManyToManyField and I'm trying to iterate the contents of that field in a comma-delimited list in my template. I'm getting some unexpected results. {% for painting in paintings_list %} <p>{% for item in painting.style.all %} {{ item.style|join:', ' }} {% endfor %}</p> {% endfor %} Th...

Django: Load template from a string (instead of from a file)

Hello, I have decided to save templates of all system emails in the DB. The body of these emails are normal django templates (with tags). This means I need the template engine to load the template from a string and not from a file. Is there a way to accomplish this ? Thanks ...

Django - Iterate over model instance field names and values in template

I'm trying to create a basic template to display the selected instance's field values, along with their names. Think of it as just a standard output of the values of that instance in table format, with the field name (verbose_name specifically if specified on the field) in the first column and the value of that field in the second colum...

Django: Displaying formset errors correctly

I have an inline formset for a model, which has a unique_together constraint. And so, when I input data, which doesn't fulfill this constraint, it displays: __all__Please correct the duplicate values below. The code, which does this is: {% for error in formset.errors %} {{ error }}<br/> {% endfor %} I don't much like...

Django Admin: Customizing the inline template (tabular.html)

I'm trying to follow the guidelines in this answer, but I'm getting stuck with how to edit the template. The relevant part of my admin.py: SegmentFormset = forms.models.inlineformset_factory(Division,Segment) class DivisionForm(forms.ModelForm): def __init__(self, **kwargs): super(DivisionForm, self).__init__(**kwargs) ...

How to get access to next object on demand in list in django template ?

Hi! It's newbie question, I think. I want to iterate above two lists: first in for loop and second when some condition is true. How do it in django template ? ...

Django tag for compressing in-page javascript

Django-compress is great, but it doesn't offer any tags for compressing in-page javascript. Are there some solutions out there? Even removing newlines (and adding ";" where needed) would be just great. ...

Easy Way to Escape Django Template Variables

For a new project we're writing documentation about the Django template system. We use Django for the documentation project itself too, so Django picks up all our example variables in the sample code and tries to render them. The only way we found to get around this is to use {% templatetag %}, but that makes our code really unreadable. ...

How can I render a Django template that has UTF8 characters in it?

I'm trying to send a django email with UTF-8 characters in the template, specifically: S'il vous plaît I get the error: UnicodeDecodeError: 'utf8' codec can't decode byte 0x94 in position 147: unexpected code byte When trying to encode the special "î" character (that is the character at that position.) Here is my code for genera...

Project name inserted automatically in url when using django template url tag

I am applying the 'url' template tag to all links in my current Django project. I have my urls named like so... url(r'^login/$', 'login', name='site_login'), This allows me to access /login at my site's root. I have my template tag defined like so... <a href="{% url site_login %}"> It works fine, except that Django automatically ...

Can I use alias field names in django templates?

Hi, I'm new to django and python... I have a model which includes 10 generic fields attrib_00 through attrib_09. I pass these fields as a context to a django template string. I would like to use more meaningful names in the template. The template strings are fetched from another model and I have in mind adding a field containing a co...

how do I know if a remote user is connected in django?

how do I know if a remote user is connected in django?, like gmail chat, or facebook chat... I need that in the templates system. Sorry for my english ...

how to activate DJANGO.CORE.CONTEXT_PROCESSORS.REQUEST

I read this "DJANGO.CORE.CONTEXT_PROCESSORS.REQUEST If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every RequestContext will contain a variable request, which is the current HttpRequest. Note that this processor is not enabled by default; you'll have to activate it. " from this page http://docs.djangoproject.com/en/dev/ref/tem...

Return function as a field on django model

I have a model which have a function to calculate the difference between two fields Example: Class MyModel(models.Model): fieldA = models.FloatField() fieldB = models.FloatField() def delta(self): return self.fieldA - self.fieldB Id like to use this model in a GenericView. I can use the function delta as an extraC...

How to update a div with an image in Django?

The following is a matplotlib code that generates a scatter plot in as the response. def plot(request): r = mlab.csv2rec('data.csv') fig = Figure(figsize=(6,6)) canvas = FigureCanvas(fig) ax = fig.add_subplot(111) ax.grid(True,linestyle='-',color='gray') ax.scatter(r.x,r.y); response=django.h...

Django templates: loop through and print all available properties of an object?

I have a database object called manor_stats, with around 30 fields. For most rows, most of these fields will be null. In my template, I'd like to loop through all the fields in the row, and print info for only the fields that aren't null. For example, there's a field called "name": I'd like to print <li>Name: {{ manor_stats.name }}</...

What's wrong here? Iterating over a dictionary in Django template

I'm trying to iterate over a dictionary of model values in a Django template - I want to list the verbose_name of each model field alongside its value. Here's what I have in models.py: class Manors(models.Model): structidx = models.IntegerField(primary_key=True, verbose_name="ID") county = models.CharField(max_length=5, nu...

NoReverseMatch error in django app

I am receiving this error in one of my templates and cant seem to figure out what's wrong. `NoReverseMatch: Reverse for 'getimagefile' with arguments '(12L, 'afN9LRzESh4I9CGe6tFVoA==\n')' and keyword arguments '{}' not found. My urls.py contains: urlpatterns = patterns('myproj.myapp.views', url(r'^getimage/(?P<extractedcontent_id>...