Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 30, 2023
1 parent f7b9a3a commit 18748bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions examples/pydantic/article/models.py
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
# )

0 comments on commit 18748bf

Please sign in to comment.