LORDCHANNEL2.0/core/context_processors.py

11 lines
387 B
Python

from .models import Profilo
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User
def userprofile(request):
if request.user.is_authenticated:
utente = get_object_or_404(User,username=request.user.username)
profilo = get_object_or_404(Profilo,user=utente)
context = {"profilo":profilo}
return context
return {}