E
E
Emin7772020-08-01 13:51:32
Python
Emin777, 2020-08-01 13:51:32

How to fix AttributeError: 'NoneType' object has no attribute 'to_dict'?

Hello. The problem is this:

elif call.data == "1":
        keyboard = types.InlineKeyboardMarkup()
        rele5 = types.InlineKeyboardButton(text="Оформить", callback_data="e")
        backbutton = types.InlineKeyboardButton(text="back", callback_data="mainmenu")
        keyboard.add(rele5, backbutton)
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                              text="Купить:",
                              reply_markup=keyboard)
    elif call.data == "e":
        keyboard = types.InlineKeyboardMarkup()
        rele1 = types.InlineKeyboarButton(text="Ввести имя пользователя", callback_data="6")
        backbutton = types.InlineKeyboardButton(text="back", callback_data="mainmenu")
        keyboard.add(rele1, backbutton)
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                              text="Введите имя пользователя :",
                              reply_markup=keyboard)


Throws an error:
AttributeError: 'NoneType' object has no attribute 'to_dict'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Miit, 2020-08-01
@Miit

We go into the translator and drive in the error there. At the output we get:

AttributeError: 'NoneType' object has no attribute 'to_dict'.

That is, you are trying to call the "Nothing" function to_dict.
And this is not the complete code, and the error log.

S
soremix, 2020-08-01
@SoreMix

And how did your code, in principle, start up and reach line 56, if it throws an error here?
rele1 = types.InlineKeyboarButton(text="Enter username", callback_data="6")
Use code editors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question