I have a django platform and I've found a strange slow performance when the server tries to response some http requests.
I've managed to isolate a little useless code that shows a strange delay, from which all the others can be derived.
case 1) If I have this function:
def get_n_events(request):
a = request.user
return HttpResponse("5")
the response is very fast, as expected:

Only 12.61ms, very fast, as expected.
case 2) But if I have this function:
def get_n_events(request):
a = request.user.username
return HttpResponse("5")
it takes more than 2 seconds!
How can be this delay explained and how can I avoid this huge time when I need to access the data inside the request? (For example, in my case I need to know the request.user.group_name, but it takes too much tome to get a response.
UPDATE
I made some tests with Django Debug Toolbar and I saw that the huge time
is not due to SQL runtime.

As we can see, the SQL takes only 183ms, but the request has 1354msecs. Where does this time come from and how can I reduce it?

request.useris a lazy objects, so as long as you do not ask for an attribute, or callstr(..), etc. over it, no database query is made.