elesire
unread,Aug 27, 2020, 11:02:19 AM8/27/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi,
I have an Member(AbstractUser) Model declare as AUTH_USER_MODEL with lot
of relations, wich have themselves a lot of relations.
It's for now quite usefull to use request.user in templates to display
relations without specifying anything in the views.
But at one time (production with lot of users) I will have an issue with
postgres queries so I wonder what is the best way to add
prefetch_related and select_related options to Member queries so that
they exist in the request.user.
I can't find in the django code where the request is populated with the
User model, but I would like to read this part.
Is it ok to update request.user via another custom templates context
processor like this request.user =
Member.objects.get(...).prefetch_related(...)... , or maybe it's not a
good idea ?
What I could do ?
1 modify the auth middleware :/
2 modify default model queries :\
3 modify it with an already existant custom templates context processor :)
4 add new instance of it (like "member") in custom templates context
processor whenever if there's duplicate entries between request.user and
member.
5 other way
I need a way.
Thanks