Re: Global variables

2009-07-29 Thread Brandon
One way to accomplish this is to use a custom context processor to add the variable to each and every response. You will need to explicitly pass in the request_context for the view(s), as far as I know, to make this work. Brandon On Jul 28, 1:19 pm, Dirso wrote: > Hi, > I created a template wit

Re: global variables in stateless applications (was "Generating dynamic csv data")

2009-03-03 Thread GP
Tim, Thanks for your tip, I was able to maintain the correct value in the current session and retrieve it in the next request as you had suggested. This solved the issue of two different clients hitting the server as they have unique session_keys. An exception here is if I have two browsers open

Re: global variables in stateless applications (was "Generating dynamic csv data")

2009-03-03 Thread GP
> This is bound to fail when user A hits view #1, then user B hits > view #1 (overwriting A's global), then user A hits view #2, > seeing B's results. Yep, figured that out the hard way > your views should be fairly stateless, relying only on > information coming from the user -- whether stored

Re: global variables in stateless applications (was "Generating dynamic csv data")

2009-03-03 Thread Tim Chase
GP wrote: > I have a view which generates a table (table_view) of the most recent > entries entered in the Test table of the database. I have the option > of querying the database and render the table based on the user > criteria as well > > Something like this: tests = Test.objects.filter(field1

Re: "Global" variables for templates

2008-06-08 Thread Armandas
That's what I was looking for. Thank you! On Jun 8, 8:14 pm, "Adi J. Sieker" <[EMAIL PROTECTED]> wrote: > Hi, > > Armandas wrote: > > Hi, I have this issue about some variables that should be available in > > templates, no matter which view is called. So far I could only think > > of making a cus

Re: "Global" variables for templates

2008-06-08 Thread Adi J. Sieker
Hi, Armandas wrote: > Hi, I have this issue about some variables that should be available in > templates, no matter which view is called. So far I could only think > of making a custom function, that would add these variables like so: > > def render(request, template, context): > #variables

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

Re: Global Variables

2006-08-22 Thread Thomas
Thanks to all of you...I have sorted the problem out...I took a look at what all of you had to say and worked through the docs again, so a big hell yeah to you all! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "D

Re: Global Variables

2006-08-21 Thread Don Arbow
On Aug 21, 2006, at 3:59 AM, Thomas wrote: > An example would be something like displaying the > First name and Last name of a user that is logged in accross all my > pages. If you need to display information about the logged in user in your template, see this page: http://www.djangoproject.c

Re: Global Variables

2006-08-21 Thread James Bennett
On 8/21/06, Thomas <[EMAIL PROTECTED]> wrote: > but I am sure there must be a simpler way of retrieving the same > information site wide and on each page where needed? Below is an > example extract from my views.py file...see what I mean? I seem to be > calling / using the "c = Context({" too man

Re: Global Variables

2006-08-21 Thread Waylan Limberg
On 8/21/06, Thomas <[EMAIL PROTECTED]> wrote: > I seem to be > calling / using the "c = Context({" too many times. Is this the best > way of doing things? An example would be something like displaying the > First name and Last name of a user that is logged in accross all my > pages. Take a look b