'NoneType' object has no attribute 'image_tag'

369 Views Asked by At

I'm trying to run my project but it is showing like there is a operational error which is none type has no attribute image_tag. Below here is my coding

    from . import models

    def get_logo(request):
        logo=models.AppSetting.objects.first()
        data={
            'logo':logo.image_tag
        }
        return data

Can anyone please help me to solve this error quickly?

2

There are 2 best solutions below

5
shivarama23 On

Can you please specify which package you are importing "models" from? It would be helpful if you describe what exactly you are trying to achieve here with this "get_logo" function. Thanks

0
Abduqayum On

from . import models

def get_logo(request):
    logo=models.AppSetting.objects.first()
    data={
        'logo':logo.image_tag
    }
    return data

just remove models.AppSetting.objects.first() and then take the path of any image and put assign it to logo it is going to be something like this def get_logo(request): logo="path of image you chose" data={ 'logo':logo } return data