Wednesday, September 12, 2012

Use get_request() instead of passing request every time

So it turns out you can simply use gadjo's get_request() to acquire the request objects instead of passing it along as parameters in your functions.

Now whenever you are in any function, and you need the request object, you can simply do..

from gadjo.requestprovider.signals import get_request

and inside your function..

def thisfunctionneedsrequest():
  <variable-name> = get_request()
  user = <variable-name>.user

So you don't need to keep passing the request object down to functions anymore. This makes things much easier.

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from JQuery Training in Chennai . or learn thru JQuery Training . or learn thru ES6 Online Training. Nowadays JavaScript has tons of job opportunities on various vertical industry.


Popular Posts