-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7b9a3a
commit 18748bf
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import datetime | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Article(BaseModel): | ||
title: str = Field(..., max_length=255) | ||
slug: str = Field(..., unique=True) | ||
content: str | ||
image: Optional[str] = None # Use str to represent the image path or URL | ||
pub_date: datetime = Field(default_factory=datetime.now) | ||
safe_for_work: bool = False | ||
minutes_to_read: int = 5 | ||
author_id: int # Assuming author is represented by an integer ID | ||
|
||
class Config: | ||
orm_mode = True | ||
|
||
|
||
# Example usage | ||
# article = Article( | ||
# title="Sample Title", | ||
# slug="sample-title", | ||
# content="Sample content", | ||
# author_id=1 | ||
# ) |