I'm making simple CRUD API using FastAPI and what I want to do is generate unique random when creating new item (other fields are address and name which should be filled by user). How can I do that?
There is fragment of my code with class and a POST function.
app = FastAPI()
userdb = []
class User(BaseModel):
id: int
address: str
name: str
@app.post("/users")
def add_user(user: User):
userdb.append(users.dict())
return userdb[-1]