Skip to content

type object 'PageBlock' has no attribute 'BLOCK_TYPE_STR'. Did you mean: 'OBJECT_TYPE_STR'? #3

@vispar-tech

Description

@vispar-tech

how to fix it?

i tried to put page to the table with to do blocks

from notion_client import Client
from basic_notion.query import Query
from basic_notion.page import NotionPage, NotionPageList
from basic_notion.block import NotionBlock, ToDoBlock, TextListField
from basic_notion.field import SelectField, TitleField, MultiSelectField, UrlField

class PageBlock(NotionBlock):
    to_do = ToDoBlock()

class MyRow(NotionPage):
    name = TitleField(property_name='Задача | Проект')
    doing = SelectField(property_name='Выполнение')
    tags = MultiSelectField(property_name='Tags')
    link = UrlField(property_name='Ссылка')

class MyData(NotionPageList[MyRow]):
    ITEM_CLS = MyRow



def get_data(database_id: str) -> MyData:
    client = Client(auth=NOTION_TOKEN)
    data = client.databases.query(
        **Query(database_id=database_id).filter(
            MyRow.name.filter.is_not_empty(True)
        ).serialize()
    )
    return MyData(data=data)

def create_page(database_id: str) -> MyRow:
    client = Client(auth=NOTION_TOKEN)
    page = MyRow.make(
        parent={'database_id': database_id},
        children = PageBlock.make(
            to_do = 'Сделать тест'
        ),
        name = ['TestPage'],
        doing = 'Слежу',
        tags = ['На проверке'],
        link = 'wildberries.com'
    )
    response = client.pages.create(**page.data)
    item = MyRow(data=response)
    return item


create_page(DATABASE_ID)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions