Re: Template syntax issues w dict

2015-05-02 Thread Bernardo Brik
just a small correction – lose the parens after items:
{% for org, num in attendees_per_org.items %}

On Friday, May 1, 2015 at 4:48:25 AM UTC-3, ADEWALE ADISA wrote:
>
> If I can understand your code, of seems you want a table of : Institution 
> | Number of attendees
> So if am right u can achive it this way :
>
> {% for org, num in attendees_per_org.items() %}
> 
> {{ org }}
> {{ num }}
> 
>   {% endfor %}
>
> Since your dataset is a dictionary, u need to use key,value to get 
> elements in both side. Also items() is also required.
> On May 1, 2015 8:22 AM, "Lachlan Musicman" > 
> wrote:
>
>> Hola,
>>
>> Django shell gives right results, template doesn't: code here
>>
>> http://dpaste.com/1NJEKD8
>>
>> What am I doing wrong?
>>
>> L.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAGBeqiN78i37JA9UJov7%2BAVbJzRt4c5YCX3em2XvN-QmefxSvg%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d130722e-737a-4116-8522-1ddf64d697f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template syntax issues w dict

2015-05-01 Thread Lachlan Musicman
 .items

Damn.

Thanks
On May 1, 2015 17:48, "ADEWALE ADISA"  wrote:

> If I can understand your code, of seems you want a table of : Institution
> | Number of attendees
> So if am right u can achive it this way :
>
> {% for org, num in attendees_per_org.items() %}
> 
> {{ org }}
> {{ num }}
> 
>   {% endfor %}
>
> Since your dataset is a dictionary, u need to use key,value to get
> elements in both side. Also items() is also required.
> On May 1, 2015 8:22 AM, "Lachlan Musicman"  wrote:
>
>> Hola,
>>
>> Django shell gives right results, template doesn't: code here
>>
>> http://dpaste.com/1NJEKD8
>>
>> What am I doing wrong?
>>
>> L.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAGBeqiN78i37JA9UJov7%2BAVbJzRt4c5YCX3em2XvN-QmefxSvg%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMGzuy_WwAKnYddxrYBL5P5O75--EP7Aqrn8a7Fg-5rUgQq02w%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiP8Kec8GN1wRabagCWasezMXF%3DHA0XBbXKUzswg9cWwPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template syntax issues w dict

2015-05-01 Thread ADEWALE ADISA
If I can understand your code, of seems you want a table of : Institution |
Number of attendees
So if am right u can achive it this way :

{% for org, num in attendees_per_org.items() %}

{{ org }}
{{ num }}

  {% endfor %}

Since your dataset is a dictionary, u need to use key,value to get elements
in both side. Also items() is also required.
On May 1, 2015 8:22 AM, "Lachlan Musicman"  wrote:

> Hola,
>
> Django shell gives right results, template doesn't: code here
>
> http://dpaste.com/1NJEKD8
>
> What am I doing wrong?
>
> L.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGBeqiN78i37JA9UJov7%2BAVbJzRt4c5YCX3em2XvN-QmefxSvg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGzuy_WwAKnYddxrYBL5P5O75--EP7Aqrn8a7Fg-5rUgQq02w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Syntax Error

2013-09-25 Thread SHANTANU SRIVASTAVA
Thanks ! The urls.py can be viewed here : http://dpaste.com/hold/1394929/

On Tuesday, September 24, 2013 1:10:57 AM UTC+5:30, Alagappan Ramu wrote:
>
> Looks like the is an issue in Django being able to resolve URLs in your 
> application. Can you paste your urls.py for more info. 
>
>
> Regards,
> Alagappan R
>
> Twitter: @_alagappan 
>
> Thanks & Regards,
> Alagappan Ramu
> +1 (716) 598 2730
>
> Graduate Student in Computer Science
> University at Buffalo, The State University of New 
> York.
>
>
>
> On Mon, Sep 23, 2013 at 7:12 AM, SHANTANU SRIVASTAVA <
> shan...@rediffmail.com > wrote:
>
>>  
>> Hi People ! Just started development with Django and am stuck with this 
>> error. When I run my admin panel from the server (default server of django) 
>> the browser shows this error "TemplateSyntaxError
>> " - Caught RuntimeError while rendering: maximum recursion depth exceeded 
>> while calling a Python object. Help me in resolving this ! Any help 
>> appreciated .
>>
>> I am developing on a 64bit x86 machine. OS-Windows - 7. 
>>
>> The tracebacks and detailed report is here : 
>> http://dpaste.com/1392716/plain/
>>
>> It is also attached as an attachment with this mail.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template Syntax Error

2013-09-23 Thread Alagappan
Looks like the is an issue in Django being able to resolve URLs in your
application. Can you paste your urls.py for more info.


Regards,
Alagappan R

Twitter: @_alagappan 

Thanks & Regards,
Alagappan Ramu
+1 (716) 598 2730

Graduate Student in Computer Science
University at Buffalo, The State University of New
York.



On Mon, Sep 23, 2013 at 7:12 AM, SHANTANU SRIVASTAVA <
shan_m...@rediffmail.com> wrote:

>
> Hi People ! Just started development with Django and am stuck with this
> error. When I run my admin panel from the server (default server of django)
> the browser shows this error "TemplateSyntaxError
> " - Caught RuntimeError while rendering: maximum recursion depth exceeded
> while calling a Python object. Help me in resolving this ! Any help
> appreciated .
>
> I am developing on a 64bit x86 machine. OS-Windows - 7.
>
> The tracebacks and detailed report is here :
> http://dpaste.com/1392716/plain/
>
> It is also attached as an attachment with this mail.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread donarb
Correction, the syntax has changed between 1.4 and 1.5. You are now 
required to quote the name in the url tag.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ijeFeRNw0aMJ.
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: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread donarb
Except, the Django documentation states that url names with dashes are 
acceptable and the examples show url tags using unquoted names. It even 
says you can use any character you want:

*The string used for the URL name can contain any characters you like. You 
are not restricted to valid Python names.*

https://docs.djangoproject.com/en/1.4/topics/http/urls/#id2

On Monday, December 3, 2012 4:54:19 AM UTC-8, Loai Ghoraba wrote:
>
> okay I found it:
>
> it should be  login 
> with quotes. Thanks.
>
> On Mon, Dec 3, 2012 at 2:50 PM, Loai Ghoraba 
> > wrote:
>
>> not working, giving: Reverse for '' with arguments '()' and keyword 
>> arguments '{}' not found.
>>
>> also I want to know about this dash (sorry for using the term score in 
>> the previous post ) thing
>>
>> On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma 
>> 
>> > wrote:
>>
>>> {% url auth_login %}
>>
>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2FM_hakKP1QJ.
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: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread Larry Martell
On Mon, Dec 3, 2012 at 7:31 AM, Loai Ghoraba  wrote:
> Hi
>
> I have this in my urls.py
>
> url(r'^accounts/login/$', login,name="accounts-login")
>
> and in a template base.html
>  login
>
> And when I try to open the site, this error is raised: Template syntax
> error: Could not parse the remainder: '-login' from 'accounts-login'
>
> But when I change the name of the url in both urls.py and base.html to
> something without the score '-', it works: like :accountslogin.
>
> So are scores banned in named urls ? I have seen scored-named-urls in the
> documentation !

Hyphens are valid in urls, but not in python. A hyphen is an operator
in python (subtraction operator), so you cannot use it in django.

-- 
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: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread Loai Ghoraba
okay I found it:

it should be  login
with quotes. Thanks.

On Mon, Dec 3, 2012 at 2:50 PM, Loai Ghoraba  wrote:

> not working, giving: Reverse for '' with arguments '()' and keyword
> arguments '{}' not found.
>
> also I want to know about this dash (sorry for using the term score in the
> previous post ) thing
>
> On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma wrote:
>
>> {% url auth_login %}
>
>
>
>

-- 
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: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread Loai Ghoraba
not working, giving: Reverse for '' with arguments '()' and keyword
arguments '{}' not found.

also I want to know about this dash (sorry for using the term score in the
previous post ) thing

On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma wrote:

> {% url auth_login %}

-- 
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: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

2012-12-03 Thread Nikhil Verma
Try Sign in

On Mon, Dec 3, 2012 at 6:01 PM, Loai Ghoraba  wrote:

> Hi
>
> I have this in my urls.py
>
> url(r'^accounts/login/$', login,name="accounts-login")
>
> and in a template base.html
>  login
>
> And when I try to open the site, this error is raised: Template syntax
> error: Could not parse the remainder: '-login' from 'accounts-login'
>
> But when I change the name of the url in both urls.py and base.html to
> something without the score '-', it works: like :accountslogin.
>
> So are scores banned in named urls ? I have seen scored-named-urls in the
> documentation !
>
> Thanks in advance.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/g19mRQ4vHd4J.
> 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.
>



-- 
Regards
Nikhil Verma
+91-958-273-3156

-- 
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: template syntax errors in production admin site (version problem?)

2010-09-30 Thread Karen Tracey
On Thu, Sep 30, 2010 at 12:39 PM, bobbymanuel wrote:

> PROBLEM SOLVED:  upgrade to Python 2.7 on server resolved issue.
> Apparrently Django 1.2.3 is not fully compatible with Python 2.5
>

I suspect it is your application code, not Django 1.2.3, that is not
compatible with Python 2.5. The error you mentioned above was:

TemplateSyntaxError at /admin/
In template
/usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/base.html,
error at line 31
Caught SyntaxError while rendering: invalid syntax (views.py, line 52)

This is saying that line 52 of a views.py file is where the Python syntax
error was encountered.My guess is you have some code on line 52 in some
views.py file in your project that uses Python syntax that was not allowed
in Python 2.5.

Why was that line even getting referenced from an attempt to load /admin/?
Line 31 of the admin/base.html template is:

31  {% url django-admindocs-docroot as docsroot %}

This {% url %} tag (any {% url %} tag) will cause all of your project's url
patterns to get loaded, which will often lead to importing your project's
view code.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
PROBLEM SOLVED:  upgrade to Python 2.7 on server resolved issue.
Apparrently Django 1.2.3 is not fully compatible with Python 2.5

On Sep 30, 11:28 am, bobbymanuel  wrote:
> interesting idea - but unfortunately, not it.
>
> i actually made a copy of admin.contrib.templates and fixed the syntax
> that its complaining about, and it starts working.
> it doesn't like the following syntax :  {% url name1 as name2 %}  -
> found in 6 places in admin.contrib.templates
> it also doesn't like {{ field.field }}  - found all over the place ;)
> if i remove those lines, ... presto magic... it works! ;(
>
> also - tested it with manage.py runserver and it produces the same
> errors.
>
> i'm wondering if it could have anything to do with 1: Windows EOL
> characters in my settings file. or 2: latin character encoding in
> MySql
> pretty much grasping at straws now.
>
> let me know if you think of anything else.
>
> Thx,
> B
>
> On Sep 30, 11:05 am, Steve Holden  wrote:
>
>
>
> > On 9/30/2010 9:50 AM, bobbymanuel wrote:
>
> > > Hi all - i've got a mysterious problem with my admin templates and I
> > > think its a version problem but can't figure it out.
>
> > > The contrib.admin templates seem to be throwing some very crazy
> > > TemplateSyntaxError(s) in many of the admin templates when i moved my
> > > app to my production environment.  I'm thinking this must be some kind
> > > of version problem so I removed django completely and reinstalled the
> > > production version and still have the same problems.  Now, the same
> > > exact project works perfectly on my development server, but the
> > > service[debian/lighttpd/fcgi] that I set up for production displays
> > > these issues - oddly enough when I first installed it, before taking
> > > the project live, it seemed to work.  I'm using the exact same path to
> > > template loaders in production/dev.
>
> > > Anyone have any ideas what's going on?  Has anyone else experienced
> > > this problem?
>
> > > Here are 2 examples of errors being thrown:
> > > ---
>
> > > TemplateSyntaxError at /admin/
> > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > > templates/admin/base.html, error at line 31
> > > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > > 21     
> > > 22     
> > > 23         
> > > 24         {% block branding %}{% endblock %}
> > > 25         
> > > 26         {% if user.is_active and user.is_staff %}
> > > 27         
> > > 28             {% trans 'Welcome,' %}
> > > 29             {% filter force_escape %}{% firstof
> > > user.first_name user.username %}{% endfilter %}.
> > > 30             {% block userlinks %}
> > > 31                 {% url django-admindocs-docroot as docsroot %}
> > > 32                 {% if docsroot %}
> > > 33                     {% trans
> > > 'Documentation' %} /
> > > 34                 {% endif %}
> > > 35                 {% url admin:password_change as password_change_url
> > > %}
> > > 36                 {% if password_change_url %}
> > > 37                     
>
> > > and
>
> > > TemplateSyntaxError at /admin/auth/group/add/
> > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > > templates/admin/includes/fieldset.html, error at line 18
> > > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > > 8              {{ line.errors }}
> > > 9              {% for field in line %}
> > > 10                  > > class="field-box"{% endif %}>
> > > 11                     {% if field.is_checkbox %}
> > > 12                         {{ field.field }}{{ field.label_tag }}
> > > 13                     {% else %}
> > > 14                         {{ field.label_tag }}
> > > 15                         {% if field.is_readonly %}
> > > 16                             {{ field.contents }}
> > > 17                         {% else %}
> > > 18                             {{ field.field }}
> > > 19                         {% endif %}
> > > 20                     {% endif %}
>
> > Is there any possibility that your server is trying to report a 500
> > error, and that it's actually the 500 template it's complaining about?
>
> > regards
> >  Steve
> > --
> > DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
interesting idea - but unfortunately, not it.

i actually made a copy of admin.contrib.templates and fixed the syntax
that its complaining about, and it starts working.
it doesn't like the following syntax :  {% url name1 as name2 %}  -
found in 6 places in admin.contrib.templates
it also doesn't like {{ field.field }}  - found all over the place ;)
if i remove those lines, ... presto magic... it works! ;(

also - tested it with manage.py runserver and it produces the same
errors.

i'm wondering if it could have anything to do with 1: Windows EOL
characters in my settings file. or 2: latin character encoding in
MySql
pretty much grasping at straws now.

let me know if you think of anything else.

Thx,
B


On Sep 30, 11:05 am, Steve Holden  wrote:
> On 9/30/2010 9:50 AM, bobbymanuel wrote:
>
>
>
>
>
> > Hi all - i've got a mysterious problem with my admin templates and I
> > think its a version problem but can't figure it out.
>
> > The contrib.admin templates seem to be throwing some very crazy
> > TemplateSyntaxError(s) in many of the admin templates when i moved my
> > app to my production environment.  I'm thinking this must be some kind
> > of version problem so I removed django completely and reinstalled the
> > production version and still have the same problems.  Now, the same
> > exact project works perfectly on my development server, but the
> > service[debian/lighttpd/fcgi] that I set up for production displays
> > these issues - oddly enough when I first installed it, before taking
> > the project live, it seemed to work.  I'm using the exact same path to
> > template loaders in production/dev.
>
> > Anyone have any ideas what's going on?  Has anyone else experienced
> > this problem?
>
> > Here are 2 examples of errors being thrown:
> > ---
>
> > TemplateSyntaxError at /admin/
> > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > templates/admin/base.html, error at line 31
> > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > 21     
> > 22     
> > 23         
> > 24         {% block branding %}{% endblock %}
> > 25         
> > 26         {% if user.is_active and user.is_staff %}
> > 27         
> > 28             {% trans 'Welcome,' %}
> > 29             {% filter force_escape %}{% firstof
> > user.first_name user.username %}{% endfilter %}.
> > 30             {% block userlinks %}
> > 31                 {% url django-admindocs-docroot as docsroot %}
> > 32                 {% if docsroot %}
> > 33                     {% trans
> > 'Documentation' %} /
> > 34                 {% endif %}
> > 35                 {% url admin:password_change as password_change_url
> > %}
> > 36                 {% if password_change_url %}
> > 37                     
>
> > and
>
> > TemplateSyntaxError at /admin/auth/group/add/
> > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > templates/admin/includes/fieldset.html, error at line 18
> > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > 8              {{ line.errors }}
> > 9              {% for field in line %}
> > 10                  > class="field-box"{% endif %}>
> > 11                     {% if field.is_checkbox %}
> > 12                         {{ field.field }}{{ field.label_tag }}
> > 13                     {% else %}
> > 14                         {{ field.label_tag }}
> > 15                         {% if field.is_readonly %}
> > 16                             {{ field.contents }}
> > 17                         {% else %}
> > 18                             {{ field.field }}
> > 19                         {% endif %}
> > 20                     {% endif %}
>
> Is there any possibility that your server is trying to report a 500
> error, and that it's actually the 500 template it's complaining about?
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: template syntax errors in production admin site (version problem?)

2010-09-30 Thread Steve Holden
On 9/30/2010 9:50 AM, bobbymanuel wrote:
> Hi all - i've got a mysterious problem with my admin templates and I
> think its a version problem but can't figure it out.
> 
> The contrib.admin templates seem to be throwing some very crazy
> TemplateSyntaxError(s) in many of the admin templates when i moved my
> app to my production environment.  I'm thinking this must be some kind
> of version problem so I removed django completely and reinstalled the
> production version and still have the same problems.  Now, the same
> exact project works perfectly on my development server, but the
> service[debian/lighttpd/fcgi] that I set up for production displays
> these issues - oddly enough when I first installed it, before taking
> the project live, it seemed to work.  I'm using the exact same path to
> template loaders in production/dev.
> 
> Anyone have any ideas what's going on?  Has anyone else experienced
> this problem?
> 
> Here are 2 examples of errors being thrown:
> ---
> 
> TemplateSyntaxError at /admin/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/base.html, error at line 31
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 21
> 22
> 23
> 24{% block branding %}{% endblock %}
> 25
> 26{% if user.is_active and user.is_staff %}
> 27
> 28{% trans 'Welcome,' %}
> 29{% filter force_escape %}{% firstof
> user.first_name user.username %}{% endfilter %}.
> 30{% block userlinks %}
> 31{% url django-admindocs-docroot as docsroot %}
> 32{% if docsroot %}
> 33{% trans
> 'Documentation' %} /
> 34{% endif %}
> 35{% url admin:password_change as password_change_url
> %}
> 36{% if password_change_url %}
> 37
> 
> and
> 
> TemplateSyntaxError at /admin/auth/group/add/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/includes/fieldset.html, error at line 18
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 8 {{ line.errors }}
> 9 {% for field in line %}
> 10 class="field-box"{% endif %}>
> 11{% if field.is_checkbox %}
> 12{{ field.field }}{{ field.label_tag }}
> 13{% else %}
> 14{{ field.label_tag }}
> 15{% if field.is_readonly %}
> 16{{ field.contents }}
> 17{% else %}
> 18{{ field.field }}
> 19{% endif %}
> 20{% endif %}
> 

Is there any possibility that your server is trying to report a 500
error, and that it's actually the 500 template it's complaining about?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template syntax

2010-09-03 Thread Daniel Roseman
On Sep 3, 5:14 pm, Javier Guerra Giraldez  wrote:
> On Fri, Sep 3, 2010 at 11:10 AM, Bradley Hintze
>
>  wrote:
> > -In my template I put {{ param1.0 }}, expecting to see the first list
> > in the list of lists.
> > Result: nothing was printed to the page.
>
> that zero becomes a string '0', not a numeric 0.  IOW, it's not
> param[0], it's (among other things) param['0'], clearly not what you
> want.

Not true. 0 is evaluated literally. {{ param1.0 }} should work, and I
have used this form many times. There's possibly something else going
wrong with the OP's template - Bradley, are you sure that the first
list wasn't output at all?
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template syntax

2010-09-03 Thread Bradley Hintze
So is there a way to access/index lists within the template?

On Fri, Sep 3, 2010 at 12:14 PM, Javier Guerra Giraldez
 wrote:
> On Fri, Sep 3, 2010 at 11:10 AM, Bradley Hintze
>  wrote:
>> -In my template I put {{ param1.0 }}, expecting to see the first list
>> in the list of lists.
>> Result: nothing was printed to the page.
>
> that zero becomes a string '0', not a numeric 0.  IOW, it's not
> param[0], it's (among other things) param['0'], clearly not what you
> want.
>
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template syntax

2010-09-03 Thread Javier Guerra Giraldez
On Fri, Sep 3, 2010 at 11:10 AM, Bradley Hintze
 wrote:
> -In my template I put {{ param1.0 }}, expecting to see the first list
> in the list of lists.
> Result: nothing was printed to the page.

that zero becomes a string '0', not a numeric 0.  IOW, it's not
param[0], it's (among other things) param['0'], clearly not what you
want.

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template syntax

2010-09-03 Thread Bradley Hintze
The dot does not work. As a test I did the following:

-In my template I put {{ param1 }}, param1 is a list of lists.
Result: param1, the lists of lists were printed to the page.

-In my template I put {{ param1.0 }}, expecting to see the first list
in the list of lists.
Result: nothing was printed to the page.

Am I doing something wrong?


On Thu, Sep 2, 2010 at 5:54 PM, Bill Freeman  wrote:
> Don't use [] subscripting, use dot.  The template engine tries using
> the thing after the dot in various ways, including as a dictionary key
> and as a list index.  So, for example:
>
>  {% ifequal param1_trunc.i "-" %}
>
> On Thu, Sep 2, 2010 at 5:11 PM, Bradley Hintze
>  wrote:
>> Hi,
>>
>> Django says that this is a TemplateSyntaxError.
>>
>> if param1_trunc[i][1]
>>
>> The i refers to an index of a for loop as shown:
>>
>> {% for i in pdb1_nums_len_dev6 %}
>>        
>>          {% ifequal param1_trunc[i] '-' %}
>>          {% else %}
>>            {% if param1_trunc[i][1] %}
>>            {% else %}
>>            
>>            {% endifequal %}
>>          {% endifequal %}
>>        {% endfor %}
>>
>> param1_trunc is a list of lists. Can I not access a object within an
>> internal list in a template llke regular python (see below)?
>>
p =[[1,2,3],[3,4,5]]
print p[0][1]
>> 2
>>
>>
>>
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template syntax

2010-09-02 Thread Bill Freeman
Don't use [] subscripting, use dot.  The template engine tries using
the thing after the dot in various ways, including as a dictionary key
and as a list index.  So, for example:

  {% ifequal param1_trunc.i "-" %}

On Thu, Sep 2, 2010 at 5:11 PM, Bradley Hintze
 wrote:
> Hi,
>
> Django says that this is a TemplateSyntaxError.
>
> if param1_trunc[i][1]
>
> The i refers to an index of a for loop as shown:
>
> {% for i in pdb1_nums_len_dev6 %}
>        
>          {% ifequal param1_trunc[i] '-' %}
>          {% else %}
>            {% if param1_trunc[i][1] %}
>            {% else %}
>            
>            {% endifequal %}
>          {% endifequal %}
>        {% endfor %}
>
> param1_trunc is a list of lists. Can I not access a object within an
> internal list in a template llke regular python (see below)?
>
>>>p =[[1,2,3],[3,4,5]]
>>>print p[0][1]
> 2
>
>
>
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template Syntax Errors

2010-07-16 Thread Karen Tracey
On Fri, Jul 16, 2010 at 5:43 AM, Jx  wrote:

>  129. self._callback = get_callable(self._callback_str)
> File "/usr/local/lib/python2.6/dist-packages/django/utils/
> functional.py" in wrapper
>  124. result = func(*args)
> File "/usr/local/lib/python2.6/dist-packages/django/core/
> urlresolvers.py" in get_callable
>  56. lookup_view = getattr(import_module(mod_name),
> func_name)
> File "/usr/local/lib/python2.6/dist-packages/django/utils/
> importlib.py" in import_module
>  35. __import__(name)
>
> Exception Type: TemplateSyntaxError at /login
> Exception Value: Caught SyntaxError while rendering: invalid syntax
> (views.py, line 13)
>
> The template i was using was just this:
>


The error is not in the template. It is in a views.py file, on line 13.
Python raised a syntax error attempting to import a views.py file (while
Django was attempting to reverse a url, which involves looking at all your
url patterns and importing all referenced views). In general exceptions
raised during template rendering (as this was) get turned into
TemplateSyntaxErrors. You need to look at the detail of the exception value
to figure out what is really going on.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Template Syntax Error: url config module not found

2009-11-09 Thread m3mitsuppe

Ok, so I narrowed this down a bit: the problem was with
get_absolute_url. I still
do not understand why it would complain about the urls.py not being
found.

I'd still be happy about any hints, but in the meantime I changed my
template code
to a not-so-DRY but working version with explicit urls.

On 9 Nov., 08:46, m3mitsuppe  wrote:
> Hi all,
>
> I have a strange error on a website I developed (quite some time
> ago...).
>
> The main url works:http://www.christina-kratzenberg.de
>
> So do all the links at the bottom except for the "portfolio" one. It's
> of course the interesting part where a photo portfolio is shown.
>
> When I click on that link, Django issues a Template Syntax Error
> saying that the module "tina.urls" cannot be importet. That's kind of
> strange, because it must have been imported this exact module for
> rendering the home page and the other pages that do work.
>
> As this happens during template rendering, I'm a bit at a loss here.
> Can anyone provide me with ideas? I don't really understand where to
> look for a solution.
>
> I'm on Django 1.0.2 with mod_python. Upgrading Django to a newer
> version and/or migrating to mod_wsgi is possible, but I don't want to
> start changing everything without understanding what's happening here.
>
> Thanks!
> Eric
--~--~-~--~~~---~--~~
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: template syntax

2009-08-19 Thread Daniel Roseman

On Aug 19, 8:55 am, elminio  wrote:
> You don't understand me.
> WQhat I want to achieve is to use student.id as a key in dictionary
> (Im talking abous template)
> If I use:
>
> {% for student in students %}
>
> ... do sth ...
>
>  {{dictionary.student.id }} 
>
> {% endfor %}
>
> using dictionary.1 works using dictionary.student.id doesnt work
> because there is no such key like student in dictionary. What can I do
> to convert student.id to value and pass it like for example dictionary.
> (student.id)
>
> if in this iteration student.id = 5 then i want to have {{ dictionary.
> 5 }}
>
> thats all

As has been explained, you can't do this straight out of the box.
However it is trivially easy to write a custom template filter that
will do it.

@register.filter
def get(dictionary, key):
return dictionary.get(key)

Now you can do {{ dictionary.get:5 }}

--
DR.
--~--~-~--~~~---~--~~
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: template syntax

2009-08-19 Thread elminio

You don't understand me.
WQhat I want to achieve is to use student.id as a key in dictionary
(Im talking abous template)
If I use:

{% for student in students %}

... do sth ...

 {{dictionary.student.id }} 

{% endfor %}

using dictionary.1 works using dictionary.student.id doesnt work
because there is no such key like student in dictionary. What can I do
to convert student.id to value and pass it like for example dictionary.
(student.id)

if in this iteration student.id = 5 then i want to have {{ dictionary.
5 }}

thats all



On Aug 18, 6:15 pm, mettwoch  wrote:
> See this:
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
>
> There's an example of iterating over key, value pairs
>
> Marc
>
> On Aug 18, 5:48 pm, elminio  wrote:
>
> > I iterate through all students and have distionary containing students
> > ids as key and for example grade as a value. I pass this dictionary to
> > the view and then while iterating through all students I though that
> > it would be simple to get appropriate value for current student. I
> > dont know how I could make it simplier in template :/ If You think so
> > maybe any ideas? but please with sample code
>
>
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread Margie

I would convert your dictionary to a list of tuples.  IE, in your
views.py code

studentTuples = [(student, dictionary.student.id) for student in
students]

Now in your template, to print out lines containing:
 student name: student id

you can do this:

{% for studentTuple in studentTuples %}
  {{studentTuple.0}} {{studentTuple.1}}
{% endfor %}


  Margie

On Aug 18, 8:48 am, elminio  wrote:
> I iterate through all students and have distionary containing students
> ids as key and for example grade as a value. I pass this dictionary to
> the view and then while iterating through all students I though that
> it would be simple to get appropriate value for current student. I
> dont know how I could make it simplier in template :/ If You think so
> maybe any ideas? but please with sample code
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread mettwoch

See this:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

There's an example of iterating over key, value pairs

Marc

On Aug 18, 5:48 pm, elminio  wrote:
> I iterate through all students and have distionary containing students
> ids as key and for example grade as a value. I pass this dictionary to
> the view and then while iterating through all students I though that
> it would be simple to get appropriate value for current student. I
> dont know how I could make it simplier in template :/ If You think so
> maybe any ideas? but please with sample code
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread elminio

sorry:
I pass this dictionary to the TEMPLATE
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread elminio

I iterate through all students and have distionary containing students
ids as key and for example grade as a value. I pass this dictionary to
the view and then while iterating through all students I though that
it would be simple to get appropriate value for current student. I
dont know how I could make it simplier in template :/ If You think so
maybe any ideas? but please with sample code


--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread Michael
On Tue, Aug 18, 2009 at 11:16 AM, elminio  wrote:

>
> Thanks for such a quick reply
>
> and what is i iterate through for example students
>
> {% for student in students %}
>  {{ dictionary.student.id }}
> {% endfor %}
>
> I want to have student.id as a key and in the way I did it above it
> doesnt work because dicttionary wants student as a key :)
>
> thanks for help


Not recommended: You either have to write a template tag (check google it
has been done before).

Recommended: Make the changes in the view and pass it to the templates
prepared. That is what views are for. This kind of logic should stay out of
the templates.

Hope that helps,

Michael

--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread elminio

Thanks for such a quick reply

and what is i iterate through for example students

{% for student in students %}
  {{ dictionary.student.id }}
{% endfor %}

I want to have student.id as a key and in the way I did it above it
doesnt work because dicttionary wants student as a key :)

thanks for help
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread mettwoch

Use:

{% name_of_your_dictionary.key_you_want_to_access %}

Remember that templates use the '.' (dot) to access keys, attributes,
indexes ...

Kindly Yours
Marc

On Aug 18, 4:55 pm, elminio  wrote:
> Hi,
>
> Im passing to the template dictionary and I would like to get by key
> to the value of that dictionary and if the key doesnt exist in it
> insert blank field into html
>
> thank You very much for help
--~--~-~--~~~---~--~~
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: template syntax

2009-08-18 Thread Michael
On Tue, Aug 18, 2009 at 10:55 AM, elminio  wrote:

>
> Hi,
>
> Im passing to the template dictionary and I would like to get by key
> to the value of that dictionary and if the key doesnt exist in it
> insert blank field into html
>
> thank You very much for help



The template language is purposefully simple. So try:

{{ dict.key }}

This will give you the value if the key exists and by default will be blank
if it does not.

Simple,

Hope that helps,

Michael

--~--~-~--~~~---~--~~
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: Template syntax question

2008-10-30 Thread Robocop

I like the suggestions, Thanks!

On Oct 28, 12:47 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 27, 10:04 pm, Robocop <[EMAIL PROTECTED]> wrote:
>
> > So i'm looking to have an admin controlled news list, and one thing in
> > particular i'd like them to be able to control is how many headlines
> > are shown on the front page, and my current code is not doing that.
>
> > The line i care about is:
>
> >         {% for New in news_list|slice:":{{limit}}"%}
>
> > where limit is some admin controlled variable that i'm certain is an
> > integer.  Is this possible?  Or is there just some error in my code
> > somewhere  that i have not seen?  Thanks!
>
> You can't nest tags like that.
>
> There are various options - have you tried defining a string in your
> view which is ":" + limit, and passing that to thetemplate? Or
> perhaps limiting news_list in your view?
>
> Or, you could define a custom filter which takes a value and returns a
> list sliced to that length. Something like (untested):
> def slice_to_var(lst, lngth):
>     return lst[:lngth]
> --
> DR.
--~--~-~--~~~---~--~~
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template syntax question

2008-10-28 Thread Daniel Roseman

On Oct 27, 10:04 pm, Robocop <[EMAIL PROTECTED]> wrote:
> So i'm looking to have an admin controlled news list, and one thing in
> particular i'd like them to be able to control is how many headlines
> are shown on the front page, and my current code is not doing that.
>
> The line i care about is:
>
>         {% for New in news_list|slice:":{{limit}}"%}
>
> where limit is some admin controlled variable that i'm certain is an
> integer.  Is this possible?  Or is there just some error in my code
> somewhere  that i have not seen?  Thanks!

You can't nest tags like that.

There are various options - have you tried defining a string in your
view which is ":" + limit, and passing that to the template? Or
perhaps limiting news_list in your view?

Or, you could define a custom filter which takes a value and returns a
list sliced to that length. Something like (untested):
def slice_to_var(lst, lngth):
return lst[:lngth]
--
DR.
--~--~-~--~~~---~--~~
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---