I have a queryset of "promotion" events which are rendered in a template. Each of these promotions also have 1 or more appointments. What I want to do is display the dates of the first and last appointments.
So far, using the "first" tag works. However, using the "last" tag causes:
TemplateSyntaxError Exception Value:
Caught an e...
I feel like I am missing something really obvious. I'm trying to use the WTForms template extensions with Django. I have a project on my development server which is working great (IE the extensions are working properly) but when I put it out on a test server, suddenly they are broken. Both servers have the same versions of Python, Dja...
The template inheritance page on the django site doesn't really solve my problem (Django 1.2).
My base page looks like:
...
<div class="grid_12" id="content">
{% block content %}{% endblock %}
</div>
...
{% block javascript %}{% endblock %}
I have another template that defines content for these:
{% block content %}
animated si...
How can I include with Django what Symfony calls 'components' - bits of logic and a template that's not associated with the content of the current page?
For example I want to include a sidebar that displays a list of the top 10 articles on the site. It should always be displayed if the user is looking at either an 'article' page or a 'v...
Wanted effect is passing the id to the request handler and populating the form with that entity. How doable is it with a template? Here are my form, request handler and template
class AForm(djangoforms.ModelForm):
text = forms.CharField(widget=forms.Textarea(attrs={'rows':'11','cols':'70','class':'foo'}),label=_("content").capitaliz...
I search template engine for PHP that's almost similar to the Django template.
...
I format text with java script and after that I store it in database, but when i get this text from database and display in a template then django do not apply css format tags , and just display them as text instead of apply. Please tell what is the problem ?
...
I don't know whether it's possible, but I'd like to be able to write something like the following:
{% with var1 var2 var3 as some_list %}
{{ some_list|maximum }}
{% endwith %}
Creating a list on the fly from an arbitrary number of template variables and/or literals seems useful, so I'm hopeful that I've overlooked something simple...
I am reading the definitive guide to django and am in Chapter 4 on template inheritance. It seems that I am not doing something as elegant as should be possible as I am having to duplicate some code for the context to appear when calling the child view. Here is the code in views.py:
def homepage(request):
current_date = datetime.da...
I’ve written a custom template tag:
def mytag(para):
return something
In my template I am getting a value {{value}}. Now I am using {{value|mytag}} to apply the tag to the value, and it is throwing a syntax error.
...
Version info:
Django version 1.3 pre-alpha SVN-13858
Ubuntu GNU/Linux 10.10
I'm totally new to i18n and l10n in Django and currently I'm trying to make my Django project available in Dutch (in addition to its default language: English). I tried to apply the instructions given at http://docs.djangoproject.com/en/dev/howto/i18n/ and ht...
I have the following code in my template that supposed to compare the value of watchinstance.shift, which can be either "DAY" or "NIGHT", to a literal string "DAY". The comparisson always fails.
{% for watchinstance in watchinstance_list %}
{% if watchinstance.shift == "DAY" %}
<p>shift is DAY</p>
{% endif %}
{% endfor %...
I am trying to display a bound ModelForm in my template.
Here the the code from the view:
assessment = Assessment.objects.get(slug=slug)
form = AssessmentForm(assessment)
But when I then pull up the template, it is empty except for the submit button.
When I try to debug with PDB, I get:
(Pdb) form.data
<Assessment: Alaska - Coastal...
I am working on a django project (my first), and in one of my views, I have a sophisticated html snippet with JS weaved within it. I would like to reuse this "component" somewhere else in the same view. Is there a way of achieving this? Please let me know if this design is faulty to begin with?
...
First try at playing with model formsets with django and was wondering how to filter by the logged in user. The view below renders a form with all the profiles when I only want them to list one (the user's one).
def create_profile(request):
ProfileFormSet = modelformset_factory(Profile)
if request.method == 'POST':
formset...
This is my template tag in a forloop
{{ product.feature_set.all.1.value }}
i want to change the number 1 to the forloop.counter. is this posible?
like:
{{
product.feature_set.all.forloop.counter.value
}}
It does not work like that, but is there a way to do this?
...
I have the following template in django, i want to get the totals of the last 2 columns for each of my document objects
{% for documento in documentos %}
{% for cuenta in documento.cuentasxdocumento_set.all %}
<tr {% cycle 'class="gray"' '' %} >
{% if forloop.first %}
<td>{{ documento.fecha_cr...
Hi.
I have a menu which shows certain information such as message_count, notifcation_count from django, and also a user profile that makes use of a load of jquery ajax functions to get information when a user clicks a url reference.
one of these reference relates to a users messages that he can view in his profile, without being redire...
I am a newbie to django, so the question might be dumb, but please feel free to teach me the right way if you know it.
I tried googling the issue, but I am still at loss.
Here's my problem:
I have a class in my model that has two foreign keys:
class X(models.Model):
name = models.CharField(max_length=30)
def __unicode__(self):
...
I'm in the midst of creating an alarm/notification system for a small Sales CRM app.
I have a Lead_Contact model that is used to store a client's name, address, etc. as well as a Contact_Notifier models that is being used to keep track of when a client was first contacted, the last contact, and when we are going to next contact them.
F...