
from .models import Profile, User 
from django.http import HttpRequest


class ProfileMiddleware:

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request:HttpRequest):
        try:
            username = request.user.get_username()
            # username = request.POST.get('username')
        except User.DoesNotExist:
            pass

        try:
            profile = Profile.objects.get(user__username= username)
            request.profile = profile
        except Profile.DoesNotExist:
            pass
        
        
        response = self.get_response(request)
        return response
394122292a49dfc2feca7e5795e5b183c416ca7d
<mask token>

<mask token>


class ProfileMiddleware:
    <mask token>

    def __call__(self, request: HttpRequest):
        try:
            username = request.user.get_username()
        except User.DoesNotExist:
            pass
        try:
            profile = Profile.objects.get(user__username=username)
            request.profile = profile
        except Profile.DoesNotExist:
            pass
        response = self.get_response(request)
        return response

<mask token>


class ProfileMiddleware:

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request: HttpRequest):
        try:
            username = request.user.get_username()
        except User.DoesNotExist:
            pass
        try:
            profile = Profile.objects.get(user__username=username)
            request.profile = profile
        except Profile.DoesNotExist:
            pass
        response = self.get_response(request)
        return response

from .models import Profile, User
from django.http import HttpRequest


class ProfileMiddleware:

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request: HttpRequest):
        try:
            username = request.user.get_username()
        except User.DoesNotExist:
            pass
        try:
            profile = Profile.objects.get(user__username=username)
            request.profile = profile
        except Profile.DoesNotExist:
            pass
        response = self.get_response(request)
        return response


from .models import Profile, User 
from django.http import HttpRequest


class ProfileMiddleware:

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request:HttpRequest):
        try:
            username = request.user.get_username()
            # username = request.POST.get('username')
        except User.DoesNotExist:
            pass

        try:
            profile = Profile.objects.get(user__username= username)
            request.profile = profile
        except Profile.DoesNotExist:
            pass
        
        
        response = self.get_response(request)
        return response