Image Generation with Background Tasks

Model and database changes required

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $30

Modified files

storeapi/database.py
--- 
+++ 
@@ -11,6 +11,7 @@
     sqlalchemy.Column("id", sqlalchemy.Integer, primary_key=True),
     sqlalchemy.Column("body", sqlalchemy.String),
     sqlalchemy.Column("user_id", sqlalchemy.ForeignKey("users.id"), nullable=False),
+    sqlalchemy.Column("image_url", sqlalchemy.String)
 )

 user_table = sqlalchemy.Table(
storeapi/tests/routers/test_post.py
--- 
+++ 
@@ -68,6 +68,7 @@
         "id": 1,
         "body": body,
         "user_id": confirmed_user["id"],
+        "image_url": None,
     }.items() <= response.json().items()
storeapi/models/post.py
--- 
+++ 
@@ -1,3 +1,5 @@
+from typing import Optional
+
 from pydantic import BaseModel, ConfigDict


@@ -10,6 +12,7 @@

     id: int
     user_id: int
+    image_url: Optional[str] = None


 class UserPostWithLikes(UserPost):