Re: Access dynamic session variable name in template

2015-07-02 Thread jorrit787
This doesn't seem to work :( def comment_upvote(request, comment_id): comment = get_object_or_404(Comment.objects.filter(id__exact=comment_id, approved=True)) votes = request.session.setdefault('commentvotes', {}) if comment.id not in votes: comment.upvotes = comment.upvote

Re: Access dynamic session variable name in template

2015-07-02 Thread Daniel Roseman
On Thursday, 2 July 2015 19:09:59 UTC+1, jorr...@gmail.com wrote: > > Hi everyone, > > I am trying to keep track of who has voted on a comment by setting session > variables like 'commentvote1', 'commentvote2', etc to True. These variable > names are dynamically generated based on the id of the c

Access dynamic session variable name in template

2015-07-02 Thread jorrit787
Hi everyone, I am trying to keep track of who has voted on a comment by setting session variables like 'commentvote1', 'commentvote2', etc to True. These variable names are dynamically generated based on the id of the comment. How can I access these dynamic variables in my template? I've tried

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Shawn Milochik
On Mon, Feb 14, 2011 at 9:53 PM, Bobby Roberts wrote: > yeah i've got it where session ends on browser close so they will > refresh when they come back and log back in.  I'm just trying to find > an efficient way to store the values so that I don't have to query on > every page. > Then see my pos

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Bobby Roberts
yeah i've got it where session ends on browser close so they will refresh when they come back and log back in. I'm just trying to find an efficient way to store the values so that I don't have to query on every page. On Feb 14, 9:19 pm, Shawn Milochik wrote: > Pickling will let you store objects

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Bobby Roberts
file.  When they login i'm loading certain pieces of their profile > into session variables.  One of these fields is the MTM and the data > is stored outside of the userprofile model in the MTM table... how > would I go about taking all of those values and making a CSV string to

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Shawn Milochik
Pickling will let you store objects as strings. However, perhaps you would like to use a memoize[1] decorator on your function. Are you trying to do this for performance reasons, because getting that relationship info from the database is slow? Regardless of why you're doing it, make sure you un

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Shawn Milochik
You can always use pickle to serialize something. What do you mean by a "many to many relationship," though? -- 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

Re: trouble storing a manytomany field in a session variable

2011-02-14 Thread Bobby Roberts
out taking all of those values and making a CSV string to save in the session variable? On Feb 14, 8:37 pm, Bobby Roberts wrote: > I'm trying to figure out how to store a manytomany relationship in a > session variable.  is the only way really to do it to loop through and > make a

trouble storing a manytomany field in a session variable

2011-02-14 Thread Bobby Roberts
I'm trying to figure out how to store a manytomany relationship in a session variable. is the only way really to do it to loop through and make a csv string and save that? -- You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Re: Setting session variable at the time of login

2011-02-09 Thread SimpleDimple
This is great, I'll definitely look into this weekend...and get back to you. On Feb 9, 11:37 pm, Matteius wrote: > You may be interested in this school system > django-classcomm:http://classcomm.googlecode.com/  demoed > athttp://classcomm.net/ I > am the primary developer on this and I have JI

Re: Setting session variable at the time of login

2011-02-09 Thread Matteius
You may be interested in this school system django-classcomm: http://classcomm.googlecode.com/ demoed at http://classcomm.net/ I am the primary developer on this and I have JIRA project management and product backlog etc. so perhaps you would be more interested in working off an existing system.

Re: Setting session variable at the time of login

2011-02-08 Thread SimpleDimple
Great Pointer - I think this is what I was looking for. On Feb 8, 2:13 am, Shawn Milochik wrote: > 1. You'll have to create your own login view. You can look at Django's > view and just copy it. You can use the built-in authentication and > template and everything, plus whatever else you want to

Re: Setting session variable at the time of login

2011-02-07 Thread Shawn Milochik
1. You'll have to create your own login view. You can look at Django's view and just copy it. You can use the built-in authentication and template and everything, plus whatever else you want to do. 2. Here's how you do that: http://docs.djangoproject.com/en/1.2/topics/auth/#storing-additional-info

Setting session variable at the time of login

2011-02-07 Thread SimpleDimple
I am new to django and building a school system but am experience developer otherwise having firm grip over rails, php, .net and java. 1) I am using django admin, I want to set a variable at the time of user login... the user login is coming from django code so I have no idea how to capture "after

How to pass session to form and customize error_message value based on session variable

2010-08-09 Thread ydjango
I have class NewEventForm(ModelForm): Event_name = forms.CharField(label='Event Name*',widget=forms.TextInput(attrs={'size':'82','maxlength':'100','tabindex':'1'}),error_messages={'required':'! You must enter Event Name.'}) description=forms.CharField(label='Event Description*', widget=Ti

Possible reasons why a session variable would be cleared out between POST requests?

2010-04-10 Thread Daniel
Hi there, I have a request.session['querySoFar'] variable that I'm appending a Q object to with each POST in order to build up a final query to run. However, this session var is getting cleared out sometimes. I have no idea why this is happening. I do not believe that I am resetting like so:

how to pass a session variable into a test request?

2009-11-12 Thread Phlip
Djangoes: This is not working (1.0.1 and 1.1.1): uri = urlresolvers.reverse('basket') self.client.session['cart'] = self.cart.pk response = self.client.post(uri) The Google traffic on this topic is a confusing mishmash of workarounds. (Take out the session object and call

Re: odd behavior with session variable that contains a list

2009-07-31 Thread Margie
Makes perfect sense, thanks for that pointer! On Jul 31, 11:17 am, Alex Gaynor wrote: > On Fri, Jul 31, 2009 at 1:15 PM, Margie wrote: > > > I am seeing some behavior with session that I don't understand.  If I > > have a session variable called recentAddIds that conta

Re: odd behavior with session variable that contains a list

2009-07-31 Thread Alex Gaynor
On Fri, Jul 31, 2009 at 1:15 PM, Margie wrote: > > I am seeing some behavior with session that I don't understand.  If I > have a session variable called recentAddIds that contains a list.  I > find that if I append to that list, like this: > >   request.session

odd behavior with session variable that contains a list

2009-07-31 Thread Margie
I am seeing some behavior with session that I don't understand. If I have a session variable called recentAddIds that contains a list. I find that if I append to that list, like this: request.session['recentAddIds'].append(newlySavedId) Then when I next receive a G

Re: KeyError on access to session variable

2009-03-10 Thread nivhab
Managed to get it to work in the meanwhile. Seems like the problem is that all of a sudden I need to restart the server each time I do a change otherwise the change is not taking affect. Not sure why this is though... On Mar 10, 3:51 pm, Daniel Roseman wrote: > On Mar 10, 12:45 pm, nivhab wrote

Re: KeyError on access to session variable

2009-03-10 Thread Daniel Roseman
On Mar 10, 12:45 pm, nivhab wrote: > Hi, > > I am trying to access a simple session attribute in the following way > (this is inside a view function): > > def setSessionData(request): >         if not request.session.get('data_was_set', False): >             comLen=get_comment_count() >          

KeyError on access to session variable

2009-03-10 Thread nivhab
Hi, I am trying to access a simple session attribute in the following way (this is inside a view function): def setSessionData(request): if not request.session.get('data_was_set', False): comLen=get_comment_count() request.session['alert_count'] = comLen

Re: Deleting a session variable

2009-01-10 Thread Christian Joergensen
Michael wrote: > Hello, > I'm sure this is a easy question. > > In one of my views I need to delete the session variable > 'request.session['percent']'. However, sometimes 'request.session > ['percent']' never gets created. When t

Deleting a session variable

2009-01-10 Thread Michael
Hello, I'm sure this is a easy question. In one of my views I need to delete the session variable 'request.session['percent']'. However, sometimes 'request.session ['percent']' never gets created. When this is the case I get an error when I do 

Re: Getting "ProgrammingError" when saving my queryset into a session variable

2008-06-30 Thread Karen Tracey
On Mon, Jun 30, 2008 at 11:54 AM, Greg <[EMAIL PROTECTED]> wrote: > > Hello, > I have the following code: > > /// > > def tracking(request): >a = Order.objects.filter(order_status=2) >request.session['tracking'] = list(a) > > /// > > Whenever i access this function I get the following erro

Getting "ProgrammingError" when saving my queryset into a session variable

2008-06-30 Thread Greg
Hello, I have the following code: /// def tracking(request): a = Order.objects.filter(order_status=2) request.session['tracking'] = list(a) /// Whenever i access this function I get the following error: ProgrammingError at /tracking/ operator does not exist: character varying = intege

Re: Should I create a session variable for this?

2007-10-14 Thread Greg
Malcolm, I got it working. Here it is: if request['b_state'] == 'KS': if request['seen_updates'] == '0': a = theamount(request, 1.06) data = request.POST.copy() data['seen_updates'] = 1 f = ContactForm(data)

Re: Should I create a session variable for this?

2007-10-14 Thread Malcolm Tredinnick
On Sun, 2007-10-14 at 18:32 -0700, Greg wrote: > Malcolm, > I think I'm finally starting to get somewhere with this. I assigned > my hidden field the initial 0 value > > seen_updates = forms.IntegerField(widget=forms.HiddenInput, initial=0) > > I was thinking that I could just do the following

Re: Should I create a session variable for this?

2007-10-14 Thread Greg
Malcolm, I think I'm finally starting to get somewhere with this. I assigned my hidden field the initial 0 value seen_updates = forms.IntegerField(widget=forms.HiddenInput, initial=0) I was thinking that I could just do the following 'request['seen_updates'] = '1'' in my view and just resend Co

Re: Should I create a session variable for this?

2007-10-14 Thread Malcolm Tredinnick
On Sun, 2007-10-14 at 17:35 -0700, Greg wrote: > Malcolm, > I've created a new form field: > > seen_updates = forms.IntegerField(widget=forms.HiddenInput) > > I've added the form field to my checkout page: > > > {{ fo.seen_updates }} > > How do I assign it a value of 0 for when the sale

Re: Should I create a session variable for this?

2007-10-14 Thread Greg
Malcolm, I've created a new form field: seen_updates = forms.IntegerField(widget=forms.HiddenInput) I've added the form field to my checkout page: {{ fo.seen_updates }} How do I assign it a value of 0 for when the sales tax has not been shown, and a 1 for when the sales tax message has

Re: Should I create a session variable for this?

2007-10-14 Thread Malcolm Tredinnick
On Sun, 2007-10-14 at 16:24 -0700, Greg wrote: > Malcolm, > Can you please show me how I would use hidden fields to let me know > that the user has seen the updated price? There's a newforms widget called HiddenInput. So if your form has a field called, say, "seen_updates", make sure you create i

Re: Should I create a session variable for this?

2007-10-14 Thread Greg
gt; > 'Submit' again and the order will be processed. > > [... code snipped ...] > > > As you can see I have problems. Is there anyway that I can do this > > without creating a session variable? The only reason I have the > > session variable is to know if

Re: Should I create a session variable for this?

2007-10-14 Thread Malcolm Tredinnick
rder. If they agree with the price increase then they can select > 'Submit' again and the order will be processed. [... code snipped ...] > As you can see I have problems. Is there anyway that I can do this > without creating a session variable? The only reason I have the &

Should I create a session variable for this?

2007-10-14 Thread Greg
7;) else: return render_to_response('checkout_form.htm', {'fo': f, 'o': request.session['cart'], 'p': theamount(request)}) else: f = ContactForm(auto_id='%s') return render_to_response('checkout

Re: User session variable in view

2007-09-14 Thread Dushyant Sharma
use RequestContext http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext pass request object to it c= RequestContext(request, {other objects}) then you can use user.fieldname in your view --~--~-~--~~~---~--~~ You received

Re: User session variable in view

2007-09-14 Thread Jarek Zgoda
Rufman napisał(a): > in temlates user information is stored in the variable user. how can i > access this data in a view. (im guessing it must be a session > variable, but i haven't found any precise information) Check the user attribute of request object. -- Jarek Zgoda Skype:

User session variable in view

2007-09-14 Thread Rufman
in temlates user information is stored in the variable user. how can i access this data in a view. (im guessing it must be a session variable, but i haven't found any precise information) thx for the help stephane --~--~-~--~~~---~--~~ You received this me

Re: Using session variable in models

2007-07-26 Thread Andreas Pfrengle
You probably also should consider if there EVER will be the possibility to support other languages. If so, you will have to do much refactoring doing it this way. Have a look at this thread: Andre

Re: Using session variable in models

2007-07-25 Thread Arnold Chen
You know? you are superb!!! Arnold On Jul 25, 7:19 am, "Wolfram Kriesing" <[EMAIL PROTECTED]> wrote: > and i forgot, this allows you to access the property "name" of the > object anywhere seemlessly, in the template, in the code, etc. this is > pretty neat imho :-) > > wolfram > > On 7/25/07, Wo

Re: Using session variable in models

2007-07-25 Thread Wolfram Kriesing
and i forgot, this allows you to access the property "name" of the object anywhere seemlessly, in the template, in the code, etc. this is pretty neat imho :-) wolfram On 7/25/07, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > after some investigation and help from the list i took this approach >

Re: Using session variable in models

2007-07-25 Thread Wolfram Kriesing
after some investigation and help from the list i took this approach and have to say it works great: from django.utils import translation @property def name(self): if translation.get_language()=="en": return self.name_en else: return self.name_de

Using session variable in models

2007-07-25 Thread Arnold Chen
I am implementing a multi-lingual product catalog website with Django. It is in English (default), Trad. Chinese and Simp. Chinese. I want to let user to choose the language they want, and the system display the corresponding product name (in the selected language). The product class is something

Re: session variable in template

2007-06-13 Thread Malcolm Tredinnick
On Wed, 2007-06-13 at 07:31 +, Dushyant Sharma wrote: > how can i use it with HttpResponseRedirect() > > like if i wish to use it as return HttpResponseRedirect('/someurl', > RequestContext(request)) You don't pass a context to HttpResponseRedirect because it doesn't render a template. Howe

Re: session variable in template

2007-06-13 Thread Dushyant Sharma
rma wrote: > > i am building single page for logged in users and anonymous users > > where i can use uid for logged in users and show specific things to > > them and for this i want to use session variable in template. i am > > trying request.session.uid in template where ui

Re: session variable in template

2007-06-12 Thread Malcolm Tredinnick
On Tue, 2007-06-12 at 13:27 +, Dushyant Sharma wrote: > i am building single page for logged in users and anonymous users > where i can use uid for logged in users and show specific things to > them and for this i want to use session variable in template. i am > trying request.se

Re: session variable in template

2007-06-12 Thread [EMAIL PROTECTED]
root }} On Jun 12, 9:27 am, Dushyant Sharma <[EMAIL PROTECTED]> wrote: > i am building single page for logged in users and anonymous users > where i can use uid for logged in users and show specific things to > them and for this i want to use session variable in template. i am > try

session variable in template

2007-06-12 Thread Dushyant Sharma
i am building single page for logged in users and anonymous users where i can use uid for logged in users and show specific things to them and for this i want to use session variable in template. i am trying request.session.uid in template where uid is session variable.. i have set

Re: session variable

2007-02-23 Thread Seth Buntin
WowI just needed to read a little bit further. Thanks. Seth --~--~-~--~~~---~--~~ 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 unsubscri

Re: session variable

2007-02-23 Thread Honza Král
On 2/23/07, Seth Buntin <[EMAIL PROTECTED]> wrote: > > So I can have for instance: > > request.session["order_items"] = [] > > and then in different view I can have: > > request.session["order_items"].append(1) > > and th

Re: session variable

2007-02-23 Thread Seth Buntin
So I can have for instance: request.session["order_items"] = [] and then in different view I can have: request.session["order_items"].append(1) and that append to the session variable? --~--~-~--~~~---~--~~ You received

Re: session variable

2007-02-23 Thread Lawrence Oluyede
On 2/23/07, Seth Buntin <[EMAIL PROTECTED]> wrote: > Can I have a list as a session variable? The session object is a dictionary-look-alike. It's available through request.session. See <http://www.djangoproject.com/documentation/sessions/> -- Lawrence, oluyede.org - n

session variable

2007-02-22 Thread Seth Buntin
Can I have a list as a session variable? I want to add potential products to a session list and if an order is placed iterate over that list and add them to an order. Or are there better ways to do this? Thanks. Seth --~--~-~--~~~---~--~~ You received this

Re: Using a session variable in templates

2006-08-02 Thread Phil Powell
That sounds like just the thing I need - to hook into every request and inject into the context dictionary. Will give it a try. Thanks Chris! On 01/08/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Context processors might work: > http://www.djangoproject.com/documentation/templates_pytho

Re: Using a session variable in templates

2006-08-01 Thread [EMAIL PROTECTED]
Context processors might work: http://www.djangoproject.com/documentation/templates_python/ Chris --~--~-~--~~~---~--~~ 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

Using a session variable in templates

2006-08-01 Thread Phil Powell
Hi all, I'm trying to implement something I'd imagine is quite simple, but have come a bit unstuck when it comes to finding a graceful way to so it. What I want to do is sotre a random number (easy enough) in the users session, then retrieve it in my base template (this is for the purpose of sel