If I understand correctly what you want, then I think sessions will help
you here: https://docs.djangoproject.com/en/1.7/topics/http/sessions/
def view_1(self, request):
request.session['display_key_list_updated'] = True
def view_2(self, request):
if request.session.get('display_key_list_updated'):
do_something()
_Nik
On 5/13/2015 2:13 PM, Henry Versemann wrote:
I have a list of one or more items being returned back to my
application as a response from a call to an API. In this particular
part of the process depending on the data keys selected by the user,
if any some data fields will be formatted automatically. When that
happens I need to add the keys to those new automatically-generated
fields to the list of data keys originally entered by the user. In the
case where there's only one item being returned, this isn't a problem,
but when I get back multiple objects in my response I only want to add
the new data field keys to the display key list once. The flag will be
initialized to false at the beginning of the process which processes
all of the responses. So the only way I could think of to do this
would be to setup some kind of global variable that can be checked and
when set to "false" then and only then update the display key list
with the keys to the new data fields. Then also at the same time set
the flag to "true", so the update doesn't happen again for each and
every subsequent item in the list of response objects. At least not
until the next request is sent and its response is being processed.
So what are my options for creating a global Boolean variable(or any
other global variable type for that matter), for accomplishing the
above task?
So far I've tried using a "global" keyword when setting up a variable,
as well as declaring a variable in a globalvars.py file, importing the
file and trying to reference it something like this:
globalvars.display_key_list_updated = True or False
But I keep getting errors of one sort or another with each way I've
tried so far (mostly exceptions.NameError).
This is my first attempt at trying to setup and use some kind of a
global variable, so its kind of frustrating, and I'm probably making
it harder than it is, but my lack of experience is getting in the way.
Thanks for the help. It is much appreciated.
Henry
--
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/8a1f173b-de34-4e34-8c34-e1512b46a05d%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/8a1f173b-de34-4e34-8c34-e1512b46a05d%40googlegroups.com?utm_medium=email&utm_source=footer>.
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/5553C064.5030401%40consbio.org.
For more options, visit https://groups.google.com/d/optout.