If less than in template language

2009-03-22 Thread Robert

Hey,
I'm trying to make a template that only reveals the first four items
of a list, and then handles the rest of the list in a different
respect, ie:

for item in list
if forloop.counter < 3 {
do something
} else {
do something else
}

but I can't come up with an eloquent way to do this in the django
template language. My ideas so far are as follows:
1. sending two lists from the view file (a bad idea because this has
to be repeated for five different lists)
2. doing an
{% ifequal __ %}

{% endifequal %}

{% ifequal __something else %}

{% endifequal %}

and so on, also not a terrific idea because it would mean having
like... 20 decision structures, and whatnot.

Any ideas are greatly appreciated!
Thanks
-Robert


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If less than in template language

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:

>
> Hey,
> I'm trying to make a template that only reveals the first four items
> of a list, and then handles the rest of the list in a different
> respect, ie:
>
> for item in list
> if forloop.counter < 3 {
> do something
> } else {
> do something else
> }
>
> but I can't come up with an eloquent way to do this in the django
> template language. My ideas so far are as follows:
> 1. sending two lists from the view file (a bad idea because this has
> to be repeated for five different lists)
> 2. doing an
> {% ifequal __ %}
>
> {% endifequal %}
>
> {% ifequal __something else %}
>
> {% endifequal %}
>
> and so on, also not a terrific idea because it would mean having
> like... 20 decision structures, and whatnot.
>
> Any ideas are greatly appreciated!
> Thanks
> -Robert
>
>
> >
>
Check out james bennet's template-utils libarary which contains an {%
iflessthan %} template tag.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If less than in template language

2009-03-22 Thread Robert

Looks great!
Stupid question... it's been a while since i've worked in django.
Where's a good place to physically store that document on the server?
sorry!

On Mar 22, 8:16 pm, Alex Gaynor  wrote:
> On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:
>
> > Hey,
> > I'm trying to make a template that only reveals the first four items
> > of a list, and then handles the rest of the list in a different
> > respect, ie:
>
> > for item in list
> > if forloop.counter < 3 {
> > do something
> > } else {
> > do something else
> > }
>
> > but I can't come up with an eloquent way to do this in the django
> > template language. My ideas so far are as follows:
> > 1. sending two lists from the view file (a bad idea because this has
> > to be repeated for five different lists)
> > 2. doing an
> > {% ifequal __ %}
>
> > {% endifequal %}
>
> > {% ifequal __something else %}
>
> > {% endifequal %}
>
> > and so on, also not a terrific idea because it would mean having
> > like... 20 decision structures, and whatnot.
>
> > Any ideas are greatly appreciated!
> > Thanks
> > -Robert
>
> Check out james bennet's template-utils libarary which contains an {%
> iflessthan %} template tag.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If less than in template language

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 10:01 PM, Robert  wrote:

>
> Looks great!
> Stupid question... it's been a while since i've worked in django.
> Where's a good place to physically store that document on the server?
> sorry!
>
> On Mar 22, 8:16 pm, Alex Gaynor  wrote:
> > On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:
> >
> > > Hey,
> > > I'm trying to make a template that only reveals the first four items
> > > of a list, and then handles the rest of the list in a different
> > > respect, ie:
> >
> > > for item in list
> > > if forloop.counter < 3 {
> > > do something
> > > } else {
> > > do something else
> > > }
> >
> > > but I can't come up with an eloquent way to do this in the django
> > > template language. My ideas so far are as follows:
> > > 1. sending two lists from the view file (a bad idea because this has
> > > to be repeated for five different lists)
> > > 2. doing an
> > > {% ifequal __ %}
> >
> > > {% endifequal %}
> >
> > > {% ifequal __something else %}
> >
> > > {% endifequal %}
> >
> > > and so on, also not a terrific idea because it would mean having
> > > like... 20 decision structures, and whatnot.
> >
> > > Any ideas are greatly appreciated!
> > > Thanks
> > > -Robert
> >
> > Check out james bennet's template-utils libarary which contains an {%
> > iflessthan %} template tag.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
Django applications are normal python modules, so anywhere on your
PythonPath(it's an enviromental variable).  Personally I keep a django_apps
directory that's all symlinked into my site-packages directory.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If less than in template language

2009-03-29 Thread Robert

Sorry, but I really am relatively new to Django, and although I've
been poking around for quite a while, I still just can't get that
package to work.
When I tried to install it inside of the contrib folder, and then add
it to the 'installed applications' in the settings.py file, i kept on
getting server errors.
having 'removed' it from the installed applications, i simply tried to
add an 'ifflessthan' to my code in the templates ({% iflessthan
counter 0 })
and I got the template error. Sorry to ask you to go into such detail,
but what exactly should I do with the template_utils file on my
server?
thanks
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---