mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2025-06-05 21:59:23 +02:00
Pagination in the admin
This commit is contained in:
12
app/utils/pagination.py
Normal file
12
app/utils/pagination.py
Normal file
@ -0,0 +1,12 @@
|
||||
import base64
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
|
||||
def encode_cursor(val: datetime) -> str:
|
||||
return base64.urlsafe_b64encode(val.isoformat().encode()).decode()
|
||||
|
||||
|
||||
def decode_cursor(cursor: str) -> datetime:
|
||||
return isoparse(base64.urlsafe_b64decode(cursor).decode())
|
Reference in New Issue
Block a user