template syntax error

2018-03-04 Thread harsh sharma
i created a model in which i have an image filed but when ever i am trying 
to get an uploaded image on the 
in my model.py 

image = models.ImageField(upload_to='static/pictures',)


setting.py

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static", "./static"),
'/var/www/static/',
]


index.html file

{% load static %}
https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5882b15f-d674-44b9-ba67-74eeecd39137%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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.


Template syntax issues w dict

2015-05-01 Thread Lachlan Musicman
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.


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.


django-extra-views, NamedFormsetsMixin template syntax?

2013-07-21 Thread Lachlan Musicman
Hola,

django-extra-views is a really good app for CBVs with FormSets (after
I wasted hours on another solution).

While reading the docs, I came across the NamedFormsetsMixin
https://github.com/AndrewIngram/django-extra-views#other-bits-of-functionality

which I thought looked nice, and implemented in my Views - which the
docs kindly explain.

I **cannot** get it to work in my templates though - I've tried
reading the tests and the code itself but cannot for the life of me
work out how to reference the now "inline_names":

views.py
class PersonCreateView(NamedFormsetsMixin, CreateWithInlinesView):
model = Person
fields = ['name']
inlines = [AddressInline, PhoneInline, EmailInline]
inline_names = ['Address', 'Phone', 'Email']

In the template person_form.py I have tried all of the following
without success:


{{ Phone }}
{{ phone }}
{{ Phones }}
{{ phones }}

{{ formset.Phone }}
{{ formset.phone }}
{{ inlines.Phone }}
{{ inlines.phone }}

{{ formset.phones }}
{{ formset.Phones }}
{{ inlines.Phones }}
{{ inlines.phones }}

{{ Phone_formset }}
{{ Phones_formset }}
{{ phone_formset }}
{{ phones_formset }}
.
{{ formset }}

I know that everything is working otherwise, because the
pre-NamedFormsetsMixin code is working:

{% for formset in inlines %}

{{ formset }}

  {% endfor %}

What the hell am I doing wrong? (I already know this is going to be a
head slapper)


cheers
L.




--
We are like a drunk blundering through a crowd of pickpockets. That we
are not poor and naked already is a testament to either the goodness
of humanity or the ineptitude of the criminal class.

http://techcrunch.com/2013/06/08/we-asked-for-this/

-- 
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 <loai1...@gmail.com> 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 <loai1...@gmail.com> 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.



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

2012-12-03 Thread Loai Ghoraba
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.



Re: Vim Django template syntax checker

2012-11-27 Thread Tom Evans
On Mon, Nov 26, 2012 at 3:39 PM, Some Developer
 wrote:
> I've been using Syntastic along with Vim for Django development for sometime
> but I'd like to see if I could improve my Vim configuration. The problem
> with Syntastic is that it does not work too well when checking partial HTML
> documents (which is often the case with Django because of template
> inheritance) and it certainly does not like the Django template tags in HTML
> documents.
>
> Does anyone know of a decent syntax checker for Vim that has full support
> for Django templates and partial HTML documents?
>
> As an aside I'm always on the look out for ways to improve my Vim
> configuration for Python / Django development so if you have any tips or
> plugins that you use to make development easier I'm all ears :).
>

It's not perfect, but ft=django should get you some reasonable
template highlighting, and ft=htmldjango will get mixed mode template
and html highlighting. It's built-in to my version of vim, 7.3.632.

For general python syntax, I use an updated one from vim.org:

http://www.vim.org/scripts/script.php?script_id=790

and have "let python_highlight_all=1" in my .vimrc

Cheers

Tom

-- 
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.



Vim Django template syntax checker

2012-11-26 Thread Some Developer
I've been using Syntastic along with Vim for Django development for 
sometime but I'd like to see if I could improve my Vim configuration. 
The problem with Syntastic is that it does not work too well when 
checking partial HTML documents (which is often the case with Django 
because of template inheritance) and it certainly does not like the 
Django template tags in HTML documents.


Does anyone know of a decent syntax checker for Vim that has full 
support for Django templates and partial HTML documents?


As an aside I'm always on the look out for ways to improve my Vim 
configuration for Python / Django development so if you have any tips or 
plugins that you use to make development easier I'm all ears :).


--
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.



Template syntax erro

2011-04-29 Thread Elton Pereira
When trying to upload or download files that contain non-ascii
caracters raise a TemplateSyntaxError exception with the following
contents:

Django Version: 1.2.5
Exception Type: TemplateSyntaxError
Exception Value:

Caught UnicodeEncodeError while rendering: 'ascii' codec can't encode
characters in position 125-126: ordinal not in range(128)

Exception Location: /usr/local/lib/python2.6/dist-packages/django/
core/files/storage.py in _open, line 137
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:['/home/protocolo/protocolo', '/home/protocolo', '/home/
protocolo/protocolo', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-
linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/
usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/
usr/lib/pymodules/python2.6', '/usr/local/lib/python2.6/dist-
packages', '/usr/lib/openoffice/basis-link/program']
Server time:Sex, 29 Abr 2011 11:56:10 -0300

I have done what is on this page but not solved:
http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

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.



Re: Problem with template syntax.

2011-03-22 Thread Malte Swart
On Tuesday, March 22, 2011 11:25:41 am dvdmchl wrote:
> I'm getting error: Invalid block tag: 'endblock', expected 'endif' in
> tempate:
> 
> {% extends "base.html" %}
> 
> {% block title %}{% endblock %}
> 
> {% block header %}
>   Header
> {% endblock %}
> 
> {% block content %}
>   {% if wiwto_category_name|length > 1 %}
>   {% for category in wiwto_category %}
>   
>   {{ 
> category.name }}
>   
>   {% endfor %}
>   {% else %}
>   List is empty.
>   {% endif% }
you have mixed the blank and %
try:
{% endif %}
> {% endblock %}   #On this
> line is the error
> 
> {% block footer %}
> 
> {% endblock %}

bye,
Malte.

-- 
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: Problem with template syntax.

2011-03-22 Thread Kenneth Gonsalves
On Tue, 2011-03-22 at 03:25 -0700, dvdmchl wrote:
> {% endif% }

{% endif %}
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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.



Problem with template syntax.

2011-03-22 Thread dvdmchl
I'm getting error: Invalid block tag: 'endblock', expected 'endif' in
tempate:

{% extends "base.html" %}

{% block title %}{% endblock %}

{% block header %}
Header
{% endblock %}

{% block content %}
{% if wiwto_category_name|length > 1 %}
{% for category in wiwto_category %}

{{ 
category.name }}

{% endfor %}
{% else %}
List is empty.
{% endif% }
{% endblock %}   #On this
line is the error

{% block footer %}

{% endblock %}


Anyone knows, where is the problem?

-- 
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.



template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
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  
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 %}

-- 
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.



Template syntax

2010-09-02 Thread Bradley Hintze
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.



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.



Template Syntax Errors

2010-07-16 Thread Jx
Hi,

i'm encountering some weird error in the template of my application.

The error enountered was:


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
csrf.py" in wrapped_view
  23. resp = view_func(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
csrf.py" in wrapped_view
  36. return view_func(*args, **kwargs)
File "/home/un0wn/mafia2/profile/views.py" in login
  854.  'form' : form,
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py" in render_to_response
  20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py" in render_to_string
  186. return t.render(context_instance)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  173. return self._render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in _render
  167. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  796. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  72. result = node.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
defaulttags.py" in render
  167. nodelist.append(node.render(context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render
  89. output = self.filter_expression.resolve(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in resolve
  579. new_obj = func(obj, *arg_vals)
File "/usr/local/lib/python2.6/dist-packages/django/template/
defaultfilters.py" in _dec
  33. args[0] = force_unicode(args[0])
File "/usr/local/lib/python2.6/dist-packages/django/utils/encoding.py"
in force_unicode
  66. s = unicode(s)
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in
__unicode__
  408. return self.as_widget()
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in
as_widget
  446. return widget.render(name, data, attrs=attrs)
File "/usr/local/lib/python2.6/dist-packages/
django_simple_captcha-0.1.7-py2.6.egg/captcha/fields.py" in render
  44. self.image_and_audio = '' %reverse('captcha-image',kwargs=dict(key=key))
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in reverse
  350. *args, **kwargs)))
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in reverse
  271. possibilities = self.reverse_dict.getlist(lookup_view)
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in _get_reverse_dict
  193. self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in _populate
  173. for name in pattern.reverse_dict:
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in _get_reverse_dict
  193. self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in _populate
  185. lookups.appendlist(pattern.callback, (bits,
p_pattern))
File "/usr/local/lib/python2.6/dist-packages/django/core/
urlresolvers.py" in _get_callback
  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:

{% for fields in form %}

 {{ fields.errors }}
{{ fields|escape }}{{ 
fields.label }}:


{% endfor %}

And the weird thing is that i have implemented the same code on
another server, but it works out fine. I got no idea what kind of
problem this is. Hope someone can enlighten me.

- 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 

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 <eric.fe...@googlemail.com> 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
-~--~~~~--~~--~--~---



Template Syntax Error: url config module not found

2009-11-08 Thread m3mitsuppe

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
-~--~~~~--~~--~--~---



template syntax

2009-08-18 Thread elminio

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 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
-~--~~~~--~~--~--~---



Template syntax question

2008-10-27 Thread Robocop

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 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: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-28 Thread laspal

Thanks a lot. Its works

On Mar 27, 8:33 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
> Specifically, you might look athttp://www.djangosnippets.org/snippets/9/.
>
> This allows you to do something like:
>
> {% expr candidate.vote_set.filter(vote='TU').count() as count %}
>
> and now {{count}} can be used in the current context.
>
> If you find yourself yearning for Total Python Power in your
> templates, you might consider using a different templating system.
> Note: I have not used either of these, but I am starting a new project
> next month and will be taking a hard look at both of them.
>
> Jinja (http://jinja.pocoo.org/) is, by design, very similar to
> Django's template syntax. It compiles the templates to Python code for
> speed. I particularly like its support for macros with arguments.
>
> There is also Mako (http://www.makotemplates.org/).
> Here is a snippet that shows how to integrate Mako with 
> Django.http://www.djangosnippets.org/snippets/97/
>
>   HTH,
>   Peter
--~--~-~--~~~---~--~~
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: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread Peter Rowell

Specifically, you might look at http://www.djangosnippets.org/snippets/9/.

This allows you to do something like:

{% expr candidate.vote_set.filter(vote='TU').count() as count %}

and now {{count}} can be used in the current context.

If you find yourself yearning for Total Python Power in your
templates, you might consider using a different templating system.
Note: I have not used either of these, but I am starting a new project
next month and will be taking a hard look at both of them.

Jinja (http://jinja.pocoo.org/) is, by design, very similar to
Django's template syntax. It compiles the templates to Python code for
speed. I particularly like its support for macros with arguments.

There is also Mako (http://www.makotemplates.org/).
Here is a snippet that shows how to integrate Mako with Django.
http://www.djangosnippets.org/snippets/97/

  HTH,
  Peter
--~--~-~--~~~---~--~~
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: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread laspal

Thanks a lot..

On Mar 27, 2:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Alternatively you can create a templatetag to accomplish this.
>
> On Mar 27, 3:14 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On Thu, Mar 27, 2008 at 3:52 PM, django <[EMAIL PROTECTED]> wrote:
>
> > >  Hi,
> > >  I want to use {[candidate.vote_set.filter(vote='TU').count()}} in my
> > >  template but not able to do it.
>
> > >  Its says Templatesyntaxerror...
> > >  I want to know how I can use the above exp in my template??
>
> > You can't. Django's template language isn't a fully-fledged Python
> > interpreter - you can't just put arbitrary python code into a template
> > and hope that it evaluates.
>
> > If you need to get the value of
> > candidate.vote_set.filter(vote='TU').count() into your template, then
> > you need to put that expression into your template context; then, you
> > can render the evaluated expression in the template.
>
> > Yours,
> > Russ Magee %-)
--~--~-~--~~~---~--~~
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: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread [EMAIL PROTECTED]

Alternatively you can create a templatetag to accomplish this.

On Mar 27, 3:14 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Thu, Mar 27, 2008 at 3:52 PM, django <[EMAIL PROTECTED]> wrote:
>
> >  Hi,
> >  I want to use {[candidate.vote_set.filter(vote='TU').count()}} in my
> >  template but not able to do it.
>
> >  Its says Templatesyntaxerror...
> >  I want to know how I can use the above exp in my template??
>
> You can't. Django's template language isn't a fully-fledged Python
> interpreter - you can't just put arbitrary python code into a template
> and hope that it evaluates.
>
> If you need to get the value of
> candidate.vote_set.filter(vote='TU').count() into your template, then
> you need to put that expression into your template context; then, you
> can render the evaluated expression in the template.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread Russell Keith-Magee

On Thu, Mar 27, 2008 at 3:52 PM, django <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>  I want to use {[candidate.vote_set.filter(vote='TU').count()}} in my
>  template but not able to do it.
>
>  Its says Templatesyntaxerror...
>  I want to know how I can use the above exp in my template??

You can't. Django's template language isn't a fully-fledged Python
interpreter - you can't just put arbitrary python code into a template
and hope that it evaluates.

If you need to get the value of
candidate.vote_set.filter(vote='TU').count() into your template, then
you need to put that expression into your template context; then, you
can render the evaluated expression in the template.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread django

Hi,
I want to use {[candidate.vote_set.filter(vote='TU').count()}} in my
template but not able to do it.

Its says Templatesyntaxerror...
I want to know how I can use the above exp in my template??

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changed template syntax?

2007-03-10 Thread sean

Hi Malcolm,
just tried the new revison and the problem is gone.
Thanks a lot for the fast fix.

Sean

> I think this should be fixed now in [4693]. Turned out to be a simple
> change, but finding the line to change took a few minutes.
>
> Please give it a run and feel free to point out any problems. I want to
> make sure this is completely backwards compatible, so any differences
> you notice are bugs. Probably best to file a ticket if you do find a
> problem, actually, so that it will hang around in a noticeable way.
>
> Best wishes,
> Malcolm


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

2007-03-09 Thread Malcolm Tredinnick

Hi Sean,

On Fri, 2007-03-09 at 23:31 +1100, Malcolm Tredinnick wrote:
> On Fri, 2007-03-09 at 04:14 -0800, sean wrote:
> > I'm having a problem with changeset 4676, that breaks some of my
> > forms.
> > These are oldforms, since I haven't had the time to update the whole
> > site to newforms.
> > For a related inline editable field i used something like:
> > {{ form.modelname.0.fieldname }}
> > but since changeset 4676 [1] this doesn't work anymore, the widget is
> > not displayed due to the template lookup failing silently in the
> > template. The field is available in the form and has the right name.
> > I don't know if this is a bug or if i never used the correct syntax
> > for these fields and it just worked.
> 
> If it stopped working in 4676, then it's a bug in that changeset. Not
> much in the way of testing for oldforms, so that's why it wasn't caught.
> 
> Sorry about that. I'll have a look at it now.

I think this should be fixed now in [4693]. Turned out to be a simple
change, but finding the line to change took a few minutes.

Please give it a run and feel free to point out any problems. I want to
make sure this is completely backwards compatible, so any differences
you notice are bugs. Probably best to file a ticket if you do find a
problem, actually, so that it will hang around in a noticeable way.

Best wishes,
Malcolm


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

2007-03-09 Thread Malcolm Tredinnick

On Fri, 2007-03-09 at 04:36 -0800, sean wrote:
> Thanks for the quick reply. I should really complete the move to
> newforms ;-)

Of course you should. :-) However, [4676] was meant to be transparent.
The problem you've pointed out looks like it might be a pain. Breaking
existing code is not cool, since after the 0.96 there will be still be
thousands of users using oldforms-compatible code.

Malcolm



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

2007-03-09 Thread sean

Thanks for the quick reply. I should really complete the move to
newforms ;-)

On Mar 9, 1:31 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> If it stopped working in 4676, then it's a bug in that changeset. Not
> much in the way of testing for oldforms, so that's why it wasn't caught.
>
> Sorry about that. I'll have a look at it now.
>
> Regards,
> Malcolm


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

2007-03-09 Thread Malcolm Tredinnick

On Fri, 2007-03-09 at 04:14 -0800, sean wrote:
> I'm having a problem with changeset 4676, that breaks some of my
> forms.
> These are oldforms, since I haven't had the time to update the whole
> site to newforms.
> For a related inline editable field i used something like:
> {{ form.modelname.0.fieldname }}
> but since changeset 4676 [1] this doesn't work anymore, the widget is
> not displayed due to the template lookup failing silently in the
> template. The field is available in the form and has the right name.
> I don't know if this is a bug or if i never used the correct syntax
> for these fields and it just worked.

If it stopped working in 4676, then it's a bug in that changeset. Not
much in the way of testing for oldforms, so that's why it wasn't caught.

Sorry about that. I'll have a look at it now.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



changed template syntax?

2007-03-09 Thread sean

I'm having a problem with changeset 4676, that breaks some of my
forms.
These are oldforms, since I haven't had the time to update the whole
site to newforms.
For a related inline editable field i used something like:
{{ form.modelname.0.fieldname }}
but since changeset 4676 [1] this doesn't work anymore, the widget is
not displayed due to the template lookup failing silently in the
template. The field is available in the form and has the right name.
I don't know if this is a bug or if i never used the correct syntax
for these fields and it just worked.
What would be the correct syntax for displaying inline editable
fields?

cheers, Sean

[1] http://code.djangoproject.com/changeset/4676


--~--~-~--~~~---~--~~
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: Simple Template Syntax Question: ljust

2006-09-25 Thread Martin Glueck

> I've tried...
>
> {{product.title |  ljust 40}}
>
> and other formats but can't get it to work...
You can use the slice filter:

{{product.title |  slice:":40" }}

or if you what the to truncate only at workbrakes, you can use the
truncatewaords filter:

{{product.title |  truncate:"5" }}

Martin

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Simple Template Syntax Question: ljust

2006-09-25 Thread Tim Shaffer

It should be

{{ product.title|ljust:"40" }}


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Simple Template Syntax Question: ljust

2006-09-25 Thread Tom Smith

Can someone show me how to get x number of chars from a variable in a  
template please...

I've tried...

{{product.title |  ljust 40}}

and other formats but can't get it to work...

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---