mirror of
https://github.com/Rushilwiz/tj2023.git
synced 2025-04-18 02:50:18 -04:00
20 lines
522 B
Python
20 lines
522 B
Python
from django.db import models
|
|
from django.conf import settings
|
|
from notion.client import NotionClient
|
|
|
|
client = NotionClient(token_v2=settings.NOTION_COOKIE)
|
|
|
|
|
|
# Create your models here.
|
|
class NotionPage(models.Model):
|
|
url = models.URLField(max_length=300)
|
|
page = None
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(NotionPage, self).__init__(*args, **kwargs)
|
|
if self.url:
|
|
self.page = client.get_block(self.url)
|
|
|
|
def __str__(self):
|
|
return str(self.page and self.page.title)
|