It seems Django doesn't use a persistent DB connection whenever I use the Request.User object.
I always get a signal saying a new DB connection occurs when I call the object.
For example:
class MyView(DetailView):
def get(self, request, slug):
print(request.user) # <--- Boom, new database connection signal is sent here.
# continue processing view
pass
Is that by design? Or is it an error?
I'd like it to use the same persistent DB connection across all requests.
I'm looking through the Django source (auth & sessions backend) and can't find where the DB connection is happening. I haven't touched the User models at all, although I do have a DB connection receiver that runs prepared statements when the app starts - it's where I found this.
Any info on this is appreciated, & happy Holidays!
-bobby
No comments:
Post a Comment