Re: Newb needs help with tracking variables in Templates

2009-01-06 Thread junker37
Yep, reading the documentation helps ;). But here's how your code should look: {% for art in my_art_list %} {% cycle '' '' '' %} {% cylce '' '' '' %} {% empty %} You

Re: Newb needs help with tracking variables in Templates

2009-01-06 Thread bruno desthuilliers
On 6 jan, 02:00, "django_fo...@codechimp.net" wrote: (snip) > First, let me take some Motrin for my very sore rear end. I have been > reading documentation. In fact, I started with the tutorials on the > site that walks you through writing the polling application, then > moved on to some doc

Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread Daniel Roseman
On Jan 5, 5:39 pm, "django_fo...@codechimp.net" wrote: > I have a pretty simple template that needs to print some data in a > bunch of table rows.  I have done something like this: > > > {% if my_art_list %} >         {% count = 0 %} >         {% for art in my_art_list %} >                 {% if

Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net
On Jan 5, 5:56 pm, bruno desthuilliers wrote: > On 5 jan, 23:39, "django_fo...@codechimp.net" > wrote: > > > I have a pretty simple template that needs to print some data in a > > bunch of table rows.  I have done something like this: > > > > > {% if my_art_list %} > >         {% count = 0 %}

Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net
I am very new to Django and Python. I have been working on a pet project that has a table of rows. My thought was to have a counter in the template, and use modulus to write out the row start/stops out. The code looks like this: {% if my_art_list %} {% count = 0 %} {% for art i

Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread bruno desthuilliers
On 5 jan, 23:39, "django_fo...@codechimp.net" wrote: > I have a pretty simple template that needs to print some data in a > bunch of table rows. I have done something like this: > > > {% if my_art_list %} > {% count = 0 %} This just won't work > {% for art in my_art_list %} >

Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net
I have a pretty simple template that needs to print some data in a bunch of table rows. I have done something like this: {% if my_art_list %} {% count = 0 %} {% for art in my_art_list %} {% if count%3 = 0 %} {% endif %}

Re: Variables in templates

2008-12-29 Thread ro60
Jeff is correct in saying that templates are just for handling layout. Django is quite strict about enforcing this separation. Having worked with a slew of other languages myself I can understand that this can be a tad inconvenient at times (even if it is best practice). A possible solution is to

Re: Variables in templates

2008-12-28 Thread Jeff Anderson
Vicky wrote: > Is there any way to create a variable within the templates...? > You'll need to be more specific. What exactly are you trying to do? You can define anything you need in your view, and then pass it to the template. Logic belongs in the view. Templates are only there to put that da

Variables in templates

2008-12-28 Thread Vicky
Is there any way to create a variable within the templates...? --~--~-~--~~~---~--~~ 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 fr

Re: variables inside variables in templates

2008-12-07 Thread Malcolm Tredinnick
On Sun, 2008-12-07 at 21:41 -0800, Vicky wrote: > Is there a way to use variables like: > > {{ content.{{ items}} }} > > ?? http://groups.google.com/group/django-users/browse_thread/thread/c7e3496fae2e1a31 That thread includes both the reason this isn't in the core templates

variables inside variables in templates

2008-12-07 Thread Vicky
Is there a way to use variables like: {{ content.{{ items}} }} ?? I need do send the object and field names to template and access content of that field from template. This thing works: {{ content.name }} But i need the thing after '.' also to be a variab

Re: assigning variables in templates

2008-10-20 Thread Chris Emerson
Hi, On Wed, Oct 15, 2008 at 01:46:38PM -0700, bmt wrote: > my problem is that when this list is empty i want to branch in the > template, and display some sort of message, instead of the usual 'for' > loop which would display the returned list. since i can't assign the > returned list to a variab

Re: assigning variables in templates

2008-10-15 Thread bmt
thanks, I forgot to mention that these are raw sql queries (because of aggregates), so the ORM cache won't help me here, but at least now I understand the reasoning behind the design more. I used a similar workaround to that what you suggested, so i read the list out in the view and passed the li

Re: assigning variables in templates

2008-10-15 Thread Malcolm Tredinnick
On Wed, 2008-10-15 at 18:21 -0500, Tim Chase wrote: > > i have to check the method's return value first with an 'if' > > tag than run the query again for the 'for' loop. this doubles > > the load on the db what i don't like, not to mention that the > > two queries may return different lists. > >

Re: assigning variables in templates

2008-10-15 Thread Tim Chase
> i have to check the method's return value first with an 'if' > tag than run the query again for the 'for' loop. this doubles > the load on the db what i don't like, not to mention that the > two queries may return different lists. Django's ORM should cache your query results, though it may need

assigning variables in templates

2008-10-15 Thread bmt
hi, i'm trying to implement a dynamic table in django. every column of the table is coded as a python object and i want to pass a list of these objects to the template as the context. every object has a method which runs a rather expensive query on the database and returns a list which can be emp

Re: Global Variables in Templates?

2007-10-08 Thread Malcolm Tredinnick
On Mon, 2007-10-08 at 04:57 -0700, lars wrote: [...] > Maybe one could post a link to this snippet in the docs? I guess I > wasn't the only > one asking for another approach? That would be overkill. This is Python. If you want a function that does the same thing over and over again, you write one

Re: Global Variables in Templates?

2007-10-08 Thread lars
> Sure, just write a short wrapper function which calls > "render_to_response" and uses a RequestContext. One example which you > can use is available on djangosnippets: > > http://www.djangosnippets.org/snippets/3/ Ah, brilliant! Problem solved =D > Having Django "automatically" do this for you

Re: Global Variables in Templates?

2007-10-08 Thread James Bennett
On 10/8/07, lars <[EMAIL PROTECTED]> wrote: > I can see why it is necessary to instantiate RequestContext with the > request object. But in terms of DRY I wonder wether there isn't a > better way? Sure, just write a short wrapper function which calls "render_to_response" and uses a RequestContext

Re: Global Variables in Templates?

2007-10-08 Thread lars
Hi! > Look at TEMPLATE_CONTEXT_PROCESSORS and use RequestContext instead of > Context in your views. See [1] for lots of details. Remember to read the > note about to pass RequestContext to render_to_response(). You mean like this: return render_to_response('my_template.html',

Re: Global Variables in Templates?

2007-10-07 Thread Malcolm Tredinnick
On Sun, 2007-10-07 at 16:21 +, niklas.voss wrote: > I searched around and haven't found anything about this Topic, so is > it possible to define Global Variables, which i can get in templates? > > So on my site i have a couple of settings, which are most time the > same and i didn't want to s

Global Variables in Templates?

2007-10-07 Thread niklas.voss
I searched around and haven't found anything about this Topic, so is it possible to define Global Variables, which i can get in templates? So on my site i have a couple of settings, which are most time the same and i didn't want to send them with every new app again with render_to_response to the

Re: form variables in templates

2007-09-22 Thread Alex Koshelev
Yes. If you had request context processor installed you can access to variables like so {{request.POST.foo}} On 22 сент, 18:47, Florian Lindner <[EMAIL PROTECTED]> wrote: > Hello, > can I access form variables (like request.POST["foo"]) in a template? Without > writing them in the argument dictio

form variables in templates

2007-09-22 Thread Florian Lindner
Hello, can I access form variables (like request.POST["foo"]) in a template? Without writing them in the argument dictionary before. Thanks, Florian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" g

Re: Accessing session variables in templates

2006-10-12 Thread patrickk
I didn´t try that, but with a combination of the following it should work: http://www.djangoproject.com/documentation/request_response/#attributes http://www.djangoproject.com/documentation/templates_python/#django- core-context-processors-request patrick Am 12.10.2006 um 19:21 schrieb Patr

Accessing session variables in templates

2006-10-12 Thread Patrick J. Anderson
Hi! I have a member_id session variable, which I set at login (it is different than "user"). I need to check that variable in my templates to display member-specific navigation. How can I check do this? Or do I need to do the checking in each view function and pass the value in a template va