Django model get current user without request

I am trying to get a user inside the django_filter model, can anyone help me with how to do that?

import django_filters
from .models import AgentVoucher
from django_filters import DateFilter, ChoiceFilter, DateFromToRangeFilter, widgets, ModelChoiceFilter
from agent.models import Agent
from django import forms
from company.models import Employee

from django_currentuser.middleware import (
    get_current_user, get_current_authenticated_user)




class AgentVoucherFilter(django_filters.FilterSet):


    date = DateFromToRangeFilter(widget=widgets.RangeWidget(attrs={'class':'form-control', 'type':'date','placeholder': 'd/m/Y'}))
    agent = ModelChoiceFilter(
        queryset =Agent.objects.filter(company = "1"), #here I want company = request.user.company 
        widget = forms.Select(attrs={'class': 'form-control select2'})
    
    )
    class Meta:
        model = AgentVoucher
        fields = ['date', "agent" ]

I am trying to use company = request.user.company

class AgentVoucherFilter(django_filters.FilterSet):

date = DateFromToRangeFilter(widget=widgets.RangeWidget(attrs={'class':'form-control', 'type':'date','placeholder': 'd/m/Y'}))
agent = ModelChoiceFilter(
    queryset =Agent.objects.filter(company = request.user.company),
    widget = forms.Select(attrs={'class': 'form-control select2'})

)
class Meta:
    model = AgentVoucher
    fields = \['date', "agent" \]

you need to define custom method for this Below is how you can proceed you can read in official docs too.

class AgentVoucherFilter(django_filters.FilterSet):

    date = DateFromToRangeFilter(widget=widgets.RangeWidget(attrs={'class':'form-control', 'type':'date','placeholder': 'd/m/Y'}))
    agent = django_filters.ModelChoiceFilter(
        field_name='agent', 
        queryset=Agent.objects.all(), 
        widget=forms.Select(attrs={'class': 'form-control select2'}),
        method='filter_agent'
    )
    class Meta:
        model = AgentVoucher
        fields = ['date', "agent" ]
    
    def filter_agent(self, queryset, name, value):
        user = get_current_authenticated_user()
        return queryset.filter(company=user.company)```


Back to Top