I have solved this problem, it is my backend code's problem :(
jiang hao在 2022年12月18日星期日上午7:59:15 [UTC+8]寫道:
> I use a for loop in django. When I refresh the browser, the result of the
> first for loop is not cleared, and the result of the second for loop is
> stitched together with the first
I use a for loop in django. When I refresh the browser, the result of the
first for loop is not cleared, and the result of the second for loop is
stitched together with the first one.
test.html:
Test
full_name
html_url
description
stargazers_count
{% for item in resp_list %}
{{ ite
TEMPLATE_STRING_IF_INVALID) or
settings.TEMPLATE_STRING_IF_INVALID
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of Mikkel Kromann
Sent: Friday, June 15, 2018 6:36 AM
To: Django users
Subject: Re: Nested for loops in templates
Thanks Matthew.
The field_list is a lis
n-a-django-template?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
>
>
>
>
>
> *From:* django...@googlegroups.com [mailto:
> django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann
> *Sent:* Wednesday, June 13, 2018 3:54 PM
> *To:* Django u
Thank you Vijay.
That link seems to be a feasible path for me to take (reproduced below).
Perhaps you or others can help me with an additional question (I am a bit
new to both Python and Django), that I'm struggling with:
Which type of data structure is Django iterating over in the templates
(i
?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of Mikkel Kromann
Sent: Wednesday, June 13, 2018 3:54 PM
To: Django users
Subject: Nested for loops in templates
Dear Django users.
T
As far as I know you can't do it directly in the templating system
Yo could write a template tag as described here
https://stackoverflow.com/questions/2894365/use-variable-as-dictionary-key-in-django-template/10700142#10700142
or use a different data structure, for example each row as a list of
Dear Django users.
Thanks to the good advice of many people on this list, I've managed to
create some nice generic class based views that work simultaneously with
many models.
The models may differ from each other with regards to the number of columns
in their data tables as well as the naming
On Mon, Jan 11, 2010 at 1:02 PM, Dave Merwin wrote:
> First of all, thanks to everyone for the help!!!
>
> I'm not getting any output after the else. Nothing displays in the
> template.
>
> That is what is confusing.
>
>
"Nothing displays in the template" sounds like either there is no user
varia
First of all, thanks to everyone for the help!!!
I'm not getting any output after the else. Nothing displays in the
template.
That is what is confusing.
Dave
On Jan 11, 8:58 am, Karen Tracey wrote:
> On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin wrote:
> > I have the following:
>
> > {% for gr
On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin wrote:
> I have the following:
>
> {% for group in user.groups.all %}
>{{ group.name }}
>{% ifequal group.name "subscribed" %}
>I'm subscribed
>{% else %}
>{{ group.name }}
>{% endifequal %}
> {% endfor %}
>
> The else p
If the docs are to be believed, {% ifequal %} does provide an option
for an {% else %} clause. See
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ifequal
That said, I can't tell from the code above why it would not work. But
if you are using Django dev version (post 1.1) then go for
i think ifequal does not accept an else in the statement.
Dave Merwin wrote:
> I have the following:
>
> {% for group in user.groups.all %}
> {{ group.name }}
> {% ifequal group.name "subscribed" %}
> I'm subscribed
> {% else %}
> {{ group.name }}
> {% endifequal %}
I have the following:
{% for group in user.groups.all %}
{{ group.name }}
{% ifequal group.name "subscribed" %}
I'm subscribed
{% else %}
{{ group.name }}
{% endifequal %}
{% endfor %}
The else part of the statement is not rendering. What am I missing?
Any help wel
I have 2 querysets:
events = event_dates.objects.select_related('evid', 'evid__type',
'evid__category').all()
inner_qs = event_dates.objects.all().values('pk').query
loc = locations.objects.filter(locid__in=inner_qs).all()
render_to_response('backup.xml', {'events': events, 'locations': loc,
'con
On Mar 12, 12:53 pm, NoviceSortOf wrote:
> In my html template i have something like
>
> {% for field in form %}
> {{ field.label_tag }}
> {{ field }}
> {% endfor %}
>
> Which loops and displays the field name and field value in the form.
>
> On smaller forms, I would prefer to do
In my html template i have something like
{% for field in form %}
{{ field.label_tag }}
{{ field }}
{% endfor %}
Which loops and displays the field name and field value in the form.
On smaller forms, I would prefer to do this manually
w/o the loop by saying something like.
...
{{
In my html template i have something like
{% for field in form %}
{{ field.label_tag }}
{{ field }}
{% endfor %}
Which loops and displays the field name and field value in the form.
On smaller forms, I would prefer to do this manually
w/o the loop by saying something like.
...
{{
In my html template i have something like
{% for field in form %}
{{ field.label_tag }}
{{ field }}
{% endfor %}
Which loops and displays the field name and field value in the form.
On smaller forms, I would prefer to do this manually
w/o the loop by saying something like.
...
{{
In my html template i have something like
{% for field in form %}
{{ field.label_tag }}
{{ field }}
{% endfor %}
Which loops and displays the field name and field value in the form.
On smaller forms, I would prefer to do this manually
w/o the loop by saying something like.
...
{{
That worked. I just updated my entries model to include comments =
generic.GenericRelation(FreeThreadedComment)
Thanks.
-Brian
On Jul 18, 12:30 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Brian, I think the solution is to add a GenericRelation to your entries
> model;
> seehttp://www.djang
Brian, without knowing exactly how your models are configured, you can do
something like this:
{{ p.comment_set.count }}
If you use it in more than one place (e.g., as {% if p.comment_set.count %}
... {{ p.comment_set.count }} ...), you will want to optimize things so that
the SQL "COUNT()" query
Brian, I think the solution is to add a GenericRelation to your entries
model; see
http://www.djangoproject.com/documentation/contenttypes/#reverse-generic-relationsfor
an explanation. I think that after doing this you'll be able to
access
p.comments.count (assuming that the generic relation is na
Hi Scott,
Thanks for your help, but I'm still having trouble.
I using django-threadedcomments
http://code.google.com/p/django-threadedcomments/
so its a little confusing.
Here are my models
http://dpaste.com/65848/
-Brian
On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Brian,
I have two tables, one is entries and the other is comments.
In the template I would like display how many comments for each entry
and some other entry data.
So far I have...
view:
entries_list = entries.objects.filter( ...)
template:
{% for p in object_list %}
{{ p.na
Nono, my searching didn't pull this up in the discussion groups, so
I'll take a look. Thanks much!
Lance
On Oct 1, 6:11 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote:
> I'm sure people are sick of me for continuing to post this, but folks keep
> asking, so I'll keep posting!
>
> In satchmo, we
I'm sure people are sick of me for continuing to post this, but folks keep
asking, so I'll keep posting!
In satchmo, we used elementree to build up such a nested list. You can see
the custom template tag here-
http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/shop/templatetags/satc
I have been unable to wrap my brain around a simple solution for the
following. I have a list of items that have a category and
subcategory. I would like to print them out in a hierarchy using the
template system.
items = [
{
'name' : 'item1',
'category' : 'foo',
'subcategory' :
f="http://yui.yahooapis.com/
2.2.2/build/treeview/assets/tree.css">
http://yui.yahooapis.com/2.2.2/build/yahoo/yahoo-</a>
min.js" >
http://yui.yahooapis.com/2.2.2/build/event/event-</a>
min.js" >
http://yui.yahooap
7;VLAN': '1', 'speed': '1000', 'port':
'Gi1/6'}], 'serial': 'XXY', 'model': 'WS-X4516-10GE', 'ports':
'6', 'card': 'S
On 7/24/07, drkfce <[EMAIL PROTECTED]> wrote:
>
> Is there any possible way to have the first loop just display the key?
Sure - you just need to walk through the data correctly.
Your context contains the `switch_info`, which is a list of
dictionaries. When you print
{% for item in switch_info %
7;,
'duplex':'auto'}]}, {'module':'2', 'type':'RJ45', 'av_ports':
[{'port':'fa2/1', 'duplex':'auto'}, {'port':'fa2/2',
'duplex':'auto'}]}]}]
If you
What you are asking is how to use a variable as a key into a
dictionary, you cannot normally do this with Django template. You
can get around it by using a template tag or try this:
{% for date in date_list.items|dictsort:"0" %}
{{ date.1 }}
{% endfor %}
Here's an explanation of how the a
Mark Jarecki wrote:
Replaced the dictionary in the views.py with a list and all was fine.
Whoops, sorry; I saw a variable called "Date_List" and didn't notice it
wasn't a list. Glad you were able to make things work.
-Zak
--~--~-~--~~~---~--~~
You received th
Replaced the dictionary in the views.py with a list and all was fine.
Thanks
Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegro
Thanks Zak,
Problem is, when I try:
{% for date in Date_List %}
{{ date }}
{% endfor %}
I get the following rendered:
1
0
3
2
5
4
6
What I'm wanting to render is:
2007-01-17
2007-01-18
2007-01-19
2007-01-20
2007-01-21
2007-01-22
2007-01-23
Not sure where I'm going wrong.
On 17/01/20
Mark Jarecki wrote:
I imagined replacing it with something like:
{% for date in Date_List %}
{{ Date_List.NotSureWhatToPutHere }}
{% endfor %}
Much like Python loop syntax:
{% for date in Date_List %}
{{ date }}
{% endfor %}
-Zak
--~--~-~--~~~---~--~~
Y
Hi there.
I'm trying to create a list of days of the upcoming week in my
template. I have the following, but would like to have the template
instead utilise a for loop instead of hard coding the days.
At present i have the following - which works:
#views.py
def detail(request):
date_l
thanks much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
F
Yes, you can have nested loops. To access the self and parent loop
counters see:
http://www.djangoproject.com/documentation/templates/#for
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To po
And if so, how do you refer to the loop counters?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this gro
On Mon, 2006-09-25 at 17:25 -0700, brad wrote:
> Now I am getting an error of:
>
> Exception Type: TypeError
> Exception Value: 'tuple' object is not callable
> Exception Location: E:\dp1\mysite\..\mysite\urls.py in ?, line 10
>
> And line ten of 'urls.py' is the following:
>
> (r'
Now I am getting an error of:
Exception Type: TypeError
Exception Value:'tuple' object is not callable
Exception Location: E:\dp1\mysite\..\mysite\urls.py in ?, line 10
And line ten of 'urls.py' is the following:
(r'^select/$', 'mysite.polls.views.select')
--~--~-~
On 9/26/06, brad <[EMAIL PROTECTED]> wrote:
>
> Hello. I am having a little trouble retreiving data from my models so
> that I can use the data in my templates to create a html select. The
> template creates the html select, but the select is not populated with
> any options, like I want it to. Th
In your view are you passing game_name into the template context?
For more info:
http://www.djangoproject.com/documentation/templates_python/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To
Hello. I am having a little trouble retreiving data from my models so
that I can use the data in my templates to create a html select. The
template creates the html select, but the select is not populated with
any options, like I want it to. Thanks in advanced for any and all
ideas to get this tem
46 matches
Mail list logo