python - Django - how to extend the session class? -


in short, want store datetime.datetime values inside session, not write in many places datetime.strftime or datetime.strptime

i use default json serializer session, , i've read why should not switch pickle.

so thought implement extending session class. write in views:

request.session.setdatetime('somekey', datetime_value) 

and

request.session.getdatetime('somekey') 

these deal converting datetime , strings.

is there simple way extend session class without messing of django internals?

i not sure, why looking extending session class. once, used requests 'session' attribute follows:

if want set session variable: simply:

       request.session['myvar'] = 'testdata' 

and access session variable:

       if 'myvar' in request.session:            myvar = request.session['myvar'] 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -