Skip to content

Commit

Permalink
Use field_serializer instead of class Config
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhai committed Oct 4, 2024
1 parent 54b6ed0 commit 8f53ee6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions llmstack/sheets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.db import models
from django.db.models.signals import post_delete
from django.dispatch import receiver
from pydantic import BaseModel, model_validator
from pydantic import BaseModel, field_serializer, model_validator

from llmstack.assets.models import Assets

Expand Down Expand Up @@ -172,10 +172,9 @@ def __init__(self, **data):
if isinstance(self.col_letter, int):
self.col_letter = self.column_index_to_letter(self.col_letter)

class Config:
json_encoders = {
SheetCellType: lambda v: v.value,
}
@field_serializer("cell_type")
def serialize_cell_type(self, cell_type: SheetCellType, _info):
return cell_type.value


class SheetCell(BaseModel):
Expand Down

0 comments on commit 8f53ee6

Please sign in to comment.