django-templates

Django Template Syntax Error in Google App Engine

I tried launching my Google App Engine app on localhost, and got a Django error I am stuck on. "TemplateSyntaxError: Template 'base/_base.html' cannot be extended, because it doesn't exist" I put the templates in a /templates, and then _base.html & index.html in /templates/base . Thanks! Emile @ proudn00b.com The Error: Traceback (m...

Using a variable as an object key in Django Template Tags

I have two 4 tier objects that I am passing to the django template. I am currently for looping through each tier, and going down a level if it exists. I ended up having key, key2 and key3 that represents the current location in the object while looping. I would like to reference the other object that has the same tiers using those variab...

How do I translate the output of a filter in Django

I have some template code that looks like: <input type='submit' value='{{ need.satisfied|yesno:"Resend this document now,Send this document now" }}' /> I'd like to be able to translate it but that appears to be difficult to accomplish. http://code.djangoproject.com/ticket/3804 mentions {{ _("Some String") }} which appears to work...

Check whether object is in QuerySet of related objects

I am building an application having to do with game achievements, and I want to display for each game, a page that lists the related achievements. That is done. However, I also want each user to be able to see in that list which achievements they have completed. My model is like this: class Achievement(models.Model): game = mode...

Get first item of QuerySet in template

In my blog app I want to display a list of blog posts and the first image connected to this post. Now I do it this way: {% for image in entry.image_set.all|slice:"1" %} <img src="{{ image.get_absolute_url }}"> {% endfor %} Is there a template shortcut I don't know about, or maybe I should just write my own Manager? ...

Django how to modify database records by template

I want to delete the records which i select, and run.html will refresh, how can i do that? Since i use function run in views.py to send records in database, and run need one parameter build which can be got by using run.name, so i think i need to pass "run.name" and "run.id" when i click the submit button. urls.py urlpatterns = pattern...

Adding extra fields not working in my django form

I have a model with a custom property class RecipeIngredient(models.Model): recipe = models.ForeignKey(Recipe) ingredient = models.ForeignKey(Ingredient) serving_size = models.ForeignKey(ServingSize) quantity = models.IntegerField() order = models.IntegerField() created = models.DateTimeField(auto_now_add = True)...

Django form pass parameter from template to view by submit button

I want to pass a parameter, when i click submit button. urls.py urlpatterns = patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), (r'^home/$', 'views.home'), (r'^home/(?P<build>[^/]+)/$', 'views.run'), (r'^run/delete/$', 'views.runDelete') ) run.html <form nam...

How can I make a verbose template tag in Django?

I have the following inclusion tag: @register.inclusion_tag('bouts/fighter/_fighter_bout_list.html') def fighter_bout_list(list, header, fighter, has, empty): return { 'list' : list, 'header': header, 'fighter': fighter, 'has' : has, 'empty' : empty, } To use it, I ca...

How to display a table of images in Django template system?

I'm developing a Django-based site for fun, and wondered if anyone knows how to solve this problem. I want to display images in a table, like a gallery, inside a template. Does anyone know how to do this? I've tried a multidimensional list, but I am getting nowhere. ...

django checkbox select all

how can i select all checkbox when i click header checkbox? By javascript? How? And can i do that in easier method? thanks:D run.html <form name="form" method="post" action="/home/{{build}}/"> <br> <input type="submit" value="Delete" style="margin-left:149px; width:80px; height:30px"> <input type="hidden" name="build_id" value="{{build...

Comparison of js andtemplate tags

<script> function compare(profile_id) { {% ifequal '{{profile.id}}' %} selected_sub='selected'; {% endifequal %} } </script> How to compare {{profile.id}} and javascript variable profile_id ...

Django - Get items in many sets

My models: class ItemSet(models.Model): name = models.CharField(max_length=30) item = models.ManyToManyField(Item) order = models.IntegerField(default=0) class Item(models.Model): name = models.CharField(max_length=30) desc = models.CharField(max_length=100) A set includes many items and a item can be in many sets...

Refresh template in Django

Hi. I have a view like this: def form1(request): if request.method == 'POST': form = SyncJobForm(request.POST) if form.is_valid(): # do something in_progress = True return render_to_response('form1.html', {'in_progress': in_progress}) I would like to know how to set it to refresh the templat...

django checkbox select all by jquery

I want to select all checkbox when i click the top check, below is my code: run.html <script language="JavaScript" src="media/js/jquery-1.4.2.min.js"></script> <script language="javascript"> $("#selectAll").change(function() { $(".xxx:checkbox").attr('checked', this.checked); }); </script> Select All: <input type="checkbox" id="sele...

Could not parse the remainder

i want to compare num and {{buildSummary_list.number}}, but why it is not work? And i got an error "Could not parse the remainder: '{{buildSummary_list.number}}' from '{{buildSummary_list.number}}'"... {% for num in buildSummary_list.paginator.page_range %} {% ifequal num {{buildSummary_list.number}} %} <b>{{num}}</b> {%...

django templates html

Hi guys, I've two different views (for instance, one for colors and other for cars ) That views point to the same template. If you click in one color, the template will show all the information about the color selected, same thing whit the car. What I'm trying to do is to insert a button to go back: <form action=""> {% ifequal back_t...

Django: using intcomma with floatformat

Found out about using intcomma with floatformat here, but have not been able to get it working. Here's what I've done: 1) Add django.contrib.humanize to installed apps 2) Add {% load humanize %} to top of template 3) Using {{ feeditem.distance|floatformat(0)|intcomma }} in the code Interestingly, floatformat:0 and floatformat:"0" did...

Refresh <div> element generated by a django template

How do I refresh a certain element within a django template? Example: {% if object.some_m2m_field.all %} <h3>The stuff I want to refresh is below</h3> <div id="the-div-that-should-be-refreshed"> {% for other_object in object.some_m2m_field.all %} <a href="www.example.com">{{ other_object.title }}</a> &nbsp; ...

Storing and escaping Django tags and filters in Django models

I am outputting content from my models to my templates, however some model fields call data stored in other models. This happens only in a few fields. I am wondering whether using an if tag to evaluate this would be more efficient compared to storing the django tags inside the models. Answers to this question say that storing django ta...