Your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt to verify.

Answer from Ignacio Vazquez-Abrams on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - It typically consists of two parts: "AttributeError" and "Object has no attribute." The former indicates the type of error, and the latter suggests that the attribute we are trying to access does not exist for the object.
Discussions

Error 'Event' object has no attribute 'get'
I have create Event in model and retrieve that value in html the error goes on please tell me solution My Code is Below: Anyone please Help me More on forum.djangoproject.com
🌐 forum.djangoproject.com
0
0
December 10, 2019
python - object has no attribute get - Stack Overflow
I am working with the tkinter module in python 3.3 I am relatively new to this and am working with entry boxes. for some reason when I run the following code I get an error message saying Attribute... More on stackoverflow.com
🌐 stackoverflow.com
AttributeError: 'Model' object has no attribute 'get'
Search before asking I have searched the YOLOv5 issues and discussions and found no similar questions. Question when I use test.py to test my model.pt, how to resolve this problem? Traceback (most ... More on github.com
🌐 github.com
4
March 26, 2022
python 3.x - 'AttributeError' : Object has no attribute 'get' - Stack Overflow
Error : AttributeError at / 'UserForm' object has no attribute 'get' I am not able to debug this error! I overlooked my codes many times, but can't able to understand where is the error being gene... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Django Forum
forum.djangoproject.com › using django
Error 'Event' object has no attribute 'get' - Using Django - Django Forum
December 10, 2019 - I have create Event in model and retrieve that value in html the error goes on please tell me solution My Code is Below: Anyone please Help me
🌐
Quora
quora.com › How-do-I-fix-AttributeError-NoneType-object-has-no-attribute-get-in-python
How to fix 'AttributeError: 'NoneType' object has no attribute 'get'' in python - Quora
How can I fix 'Python AttributeError: object has no attribute' in Python? ... That error means you tried to call .get(...) on a value that is None. Fixing it requires locating where that None is coming from and handling it explicitly.
🌐
JanBask Training
janbasktraining.com › community › python-python › why-am-i-getting-attributeerror-object-has-no-attribute
Why am I getting AttributeError: Object has no attribute | JanBask Training Community
April 17, 2021 - Run the script with python -tt to verify. ... The "AttributeError: Object has no attribute" error occurs in Python when you try to access or call an attribute or method that does not exist on an object.
Find elsewhere
🌐
GitHub
github.com › ultralytics › yolov5 › issues › 7151
AttributeError: 'Model' object has no attribute 'get' · Issue #7151 · ultralytics/yolov5
March 26, 2022 - Traceback (most recent call last): File "/workspace/code/test.py", line 314, in <module> test(opt.data, File "/workspace/code/test.py", line 57, in test model = attempt_load(weights, map_location=device) # load FP32 model File "/workspace/code/models/experimental.py", line 120, in attempt_load print(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1177, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'Model' object has no attribute 'get' No response ·
Author   falser101
🌐
GeeksforGeeks
geeksforgeeks.org › python-attributeerror
Python: AttributeError - GeeksforGeeks
January 3, 2023 - --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-9-c26cd169473f> in <module> ----> 1 d.getkeys() AttributeError: 'dict_parsing' object has no attribute 'getkeys'
🌐
GitHub
github.com › python-mode › python-mode › issues › 1177
'Error' object has no attribute 'get' · Issue #1177 · python-mode/python-mode
November 6, 2023 - 1 more line; before #1 5 seconds ago "lint.py" 105L, 3112B [w] Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/user1/.vim/bundle/python-mode/pymode/lint.py", line 91, in code_check errors = sorted(errors, key=__sort) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/user1/.vim/bundle/python-mode/pymode/lint.py", line 85, in __sort return sort_rules.index(e.get('type')) ^^^^^ AttributeError: 'Error' object has no attribute 'get' When I omit/comment line with sorting there is no AttributeError, but errors from linter are not sorted.
Author   PawelKra
🌐
CodeWithHarry
codewithharry.com › blogpost › attribute-error-in-python
[Solved] Python AttributeError: object has no attribute 'X' | Blog | CodeWithHarry
April 5, 2025 - Attribute Errors emerge when an ... are a few common scenarios that can lead to Attribute Errors: If you try to access an attribute that hasn't been defined for the object, Python raises an Attribute Error....
🌐
Reddit
reddit.com › r/django › attributeerror at /post/ 'post' object has no attribute 'get'
r/django on Reddit: AttributeError at /Post/ 'Post' object has no attribute 'get'
February 1, 2021 -

Hi. I have this problem "AttributeError at /Post/ 'Post' object has no attribute 'get'"

and have no clue why it happens. I am using a django filter and it's my first time trying "foreignkey"

There are two simple models and Post_price is the one that has a foreignkey attribute.

Thank you for your help in advance.

<These are the models.py files>

class Post(models.Model):

name= models.CharField(max_length=11,default='')

class Post_price(models.Model):

post= models.ForeignKey('Post', blank=True, null=True, on_delete=models.SET_NULL)

content= models.IntegerField(default='')

<it's a django filter file>

class PostFilter(django_filters.FilterSet):

class Meta:

model = Post

fields = {

'name': ...(I just handled it well)

<This one is for views.py>

def Post(request):

s = Post.objects.all()

aq = PostFilter(request.GET, queryset=s)

return render(request,'app/Post.html',{'s':aq})

<just in case urls.py's path part>

path('Post/',Post,name='Post'),

🌐
Reddit
reddit.com › r/learnpython › object has no attribute error, but it actually does..
r/learnpython on Reddit: Object has no attribute error, but it actually does..
September 17, 2022 -

hello, i am working on a game using pygame and i am going for an OOP approach, the files are pretty big, i will post only a portion of the code; also i am using pycharm so i know for a fact my identation, typing are alright.. plus i have been coding in python for a while now but i just can't grasp onto this issue :(, so far in the game i am just in the main menu phase and whenever i try to run my code i get an error that my game object (which has a reference to another class including the main menu game loop) has no attribute ''screenWidth'' but it actually does have a variable for my screen.. i just use it in the main menu to set another midWidth variable half of that variable as value
here is the code:

main.py

from game import Game

myGame = Game()

while myGame.running:
    myGame.currentMenu.drawMainMenu()
    myGame.gameLoop()

game.py

import pygame
from menu import MainMenu


class Game:
    def __init__(self):
        pygame.init()

        self.running, self.playing = True, False
        self.upKey, self.downKey, self.selectKey, self.backKey = False, False, False, False

        self.currentMenu = MainMenu(self)

        self.screenWidth = 1280
        self.screenHeight = 720
        self.gameWindow = pygame.display.set_mode((self.screenWidth, self.screenHeight))
        pygame.display.set_caption("Game Prototype")

        self.backgroundImage = pygame.image.load('Assets/Images/bg_greek.jpg')
        self.backgroundImage = pygame.transform.scale(self.backgroundImage, (1920, 1080))

    def gameLoop(self):
        while self.playing:
            self.checkEvents()

            if self.selectKey:
                self.playing = False

            self.gameWindow.blit(self.backgroundImage, (-600, -300))

            pygame.display.flip()
            self.resetKeys()

menu.py

import pygame


class Menu:
    def __init__(self, game):
        self.gameClass = game
        self.midWidth = self.gameClass.screenWidth / 2
        self.midHeight = self.gameClass.screenHeight / 2
        self.showMenu = True
        self.selectionX, self.selectionY = 0, 0

    def drawSelection(self):
        selectSurface = pygame.Surface((260, 100), pygame.SRCALPHA)
        selectSurface.fill((50, 50, 50, 175))
        selectRect = selectSurface.get_rect()
        selectRect.center = (self.selectionX, self.selectionY)
        self.gameClass.gameWindow.blit(selectSurface, selectRect)


class MainMenu(Menu):
    def __init__(self, game):
        Menu.__init__(self, game)
        self.hoveredState = "Start"
        self.startX, self.startY = self.midWidth, self.midHeight
        self.optionsX, self.optionsY = self.midWidth, self.midHeight + 100
        self.creditsX, self.creditsY = self.midWidth, self.midHeight + 200
        self.quitX, self.quitY = self.midWidth, self.midHeight + 300
        self.selectionX, self.selectionY = self.startX, self.startY

    def drawMainMenu(self):
        self.showMenu = True
        while self.showMenu:
            self.gameClass.checkEvents()
            self.checkInput()

            self.gameClass.gameWindow.blit(self.gameClass.backgroundImage, (-600, -300))
            self.drawSelection()
            self.gameClass.drawText("Play", 72, self.startX, self.startY)
            self.gameClass.drawText("Options", 72, self.optionsX, self.optionsY)
            self.gameClass.drawText("Credits", 72, self.creditsX, self.creditsY)
            self.gameClass.drawText("Quit", 72, self.quitX, self.quitY)

            pygame.display.flip()
            self.gameClass.resetKeys()

it is not complete though

🌐
Rollbar
rollbar.com › home › how to fix attributeerror in python
How to Fix AttributeError in Python | Rollbar
October 17, 2022 - The Python help() function can be used to find out all attributes and methods related to the object. To resolve the AttributeError, a try-except block can be used. The lines of code that can throw the AttributeError should be placed in the try block, and the except block can catch and handle the error. Using the above approach, the previous example can be updated to handle the error: i = 1 try: i.append(2) except AttributeError: print('No such attribute')>
🌐
GitHub
github.com › thatmattlove › hyperglass › issues › 316
AttributeError: object has no attribute 'get' · Issue #316 · thatmattlove/hyperglass
January 25, 2025 - AttributeError: 'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'get'
Author   BrunoBlanes
🌐
GitHub
github.com › open-mmlab › mmdetection › issues › 10669
AttributeError: 'NoneType' object has no attribute 'get' · Issue #10669 · open-mmlab/mmdetection
July 20, 2023 - Traceback (most recent call last): File "tools/train.py", line 133, in <module> main() File "tools/train.py", line 122, in main runner = Runner.from_cfg(cfg) File "/home/aaa/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/runner.py", line 444, in from_cfg runner = cls( File "/home/aaa/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/runner.py", line 354, in __init__ self.setup_env(env_cfg) File "/home/aaa/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/runner.py", line 648, in setup_env if env_cfg.get('cudnn_benchmark'): AttributeError: 'NoneType' object has no attribute 'get'
Author   Younger330
🌐
sebhastian
sebhastian.com › object-has-no-attribute-python-class
How to fix AttributeError: object has no attribute in Python class | sebhastian
February 17, 2023 - Traceback (most recent call last): File "main.py", line 10, in <module> person.eat() AttributeError: 'Human' object has no attribute 'eat' To fix this you need to define the eat() method inside the class as follows: class Human: def __init__(self, ...
🌐
freeCodeCamp
forum.freecodecamp.org › python
Python: AttributeError - Python - The freeCodeCamp Forum
September 2, 2022 - import random class Deck: def ___init__(self): self.cards = [] suits = ["spades", "clubs", "hearts", "diamonds"] ranks = [{"rank": "A", "value": 11}, {"rank": "2", "value": 2}, {"rank": "3", "value": 3}, {"rank": "4", "value": 4}, {"rank": "5", "value": 5}, {"rank": "6", "value": 6}, {"rank": "7", "value": 7}, {"rank": "8", "value": 8}, {"rank": "9", "value": 9}, {"rank": "J...