Image not loading on a class based view DJANGO for Twitter Card

I am trying to load the image on Twitter card and i am using ‘SITE_PROTOCOL_URL’: request._current_scheme_host, in function based views it is working well but in a class based view its not loading. I tried different ways but still doesnt work and i am stuck on it

here is my code in view:

def category(request,slug,pk):
    query_pk_and_slug = True
    katego=Kategori.objects.all()
    kategorit=Kategori.objects.get(title=slug, fotot_e_kategoris=slug)
    lajmet=Lajmet.objects.filter(kategorit=kategorit, verified=True).order_by('-data_e_postimit')
    lajms=Lajmet.objects.filter(kategorit=kategorit, verified=True).order_by('-data_e_postimit')[3:]
    lajmets=Lajmet.objects.filter(kategorit=kategorit, verified=True).order_by('-data_e_postimit')[7:]
    sponsor=SponsorPost.objects.all().order_by('-data_e_postimit')
    
    paginator = Paginator(lajmets, 15)
   
    page_number = request.GET.get('page')
   
    page_obj = paginator.get_page(page_number)
    
    return render(request,'main/category-news.html',{
        'SITE_PROTOCOL_URL': request._current_scheme_host,
        'lajmet':lajmet,
        'kategorit':kategorit,
        'katego': katego,
        'lajms': lajms,
        'page_obj': page_obj,
        'sponsor':sponsor
    })


class LajmetListView(ListView):
    model = Kategori
    model = Lajmet
    template_name = 'main/lajme-home.html' # <app>/<model>_<viewtype>.html
    context_object_name = 'lajmets'
    query_pk_and_slug = True

    def get_context_data(self, **kwargs):
        context = super(LajmetListView, self).get_context_data(**kwargs)
        context['lajmet'] = Lajmet.objects.order_by('-data_e_postimit').filter(verified=True)
        context['katego'] = Kategori.objects.all()
        context['shikime'] = Lajmet.objects.all().order_by('-shikime')
        context['SITE_PROTOCOL_URL'] = self.request._current_scheme_host
        return context

And Template :

{% if object.slug in request.path %}
    <title>{{object.titulli}}</title>
    <meta name="twitter:card" value="summary_large_image">
    <meta name="twitter:site" content="@gazetarja_">
    <meta name="twitter:creator" content="@SimonGjokaj">
    <meta name="twitter:title" content="{{object.titulli}}">
    <meta name="twitter:description" property="og:description" content="{{object.detajet|striptags|truncatewords:30}}">
    <meta name='twitter:image' content="{{SITE_PROTOCOL_URL}}{{object.fotografit.url}}">

    {% elif request.path == '/' %}
    <title>Portali Gazetarja - LAJMI FUNDIT</title>
    <meta name="twitter:card" value="summary_large_image">
    <meta name="twitter:site" content="@gazetarja_">
    <meta name="twitter:creator" content="@SimonGjokaj">'
    <meta name="twitter:title" content="Portali Gazetarja - LAJMI FUNDIT">
    <meta name="twitter:description" content="Gazetarja i'u sjell në kohë reale, sekond pas sekonde informacione dhe lajme, këshilla dhe analiza nga të gjitha sferat e jetës.">
    <meta name="twitter:image" content="{{SITE_PROTOCOL_URL}}{% static '/vendor/img/profilelogito.jpg' %}">

    {% else %}
     <title>{{ kategorit.title }} - Portali Gazetarja</title>
     <meta name="twitter:card" value="summary_large_image">
     <meta name="twitter:site" content="@gazetarja_">
     <meta name="twitter:creator" content="@SimonGjokaj">'
     <meta name="twitter:title" content="{{ kategorit.title }} - Portali Gazetarja">
     <meta name="twitter:description" content="Gazetarja i'u sjell në kohë reale, sekond pas sekonde informacione dhe lajme, këshilla dhe analiza nga të gjitha sferat e jetës.">
     <meta name="twitter:image" content="{{SITE_PROTOCOL_URL}}{% static '/vendor/img/profilelogito.jpg' %}">
     {% endif %}

Source: Python Questions

LEAVE A COMMENT