Git Product home page Git Product logo

basic-notion's People

Contributors

altvod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

basic-notion's Issues

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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.