Skip to content

Instantly share code, notes, and snippets.

@rafaelcanovas
Last active April 30, 2021 17:11
Show Gist options
  • Save rafaelcanovas/f891317e9214eb695ea95951b4e6f3f2 to your computer and use it in GitHub Desktop.
Save rafaelcanovas/f891317e9214eb695ea95951b4e6f3f2 to your computer and use it in GitHub Desktop.
FastAPI + Django: app.py
import django # noqa
django.setup() # noqa
import uvicorn
from fastapi import FastAPI
from django.db.utils import OperationalError
from users.models import UserModel
from users.responses import UserResponse
app = FastAPI()
@app.get('/')
def root():
users = UserModel.objects.all()
return UserListResponse.from_queryset(users)
if __name__ == '__main__':
uvicorn.run('main:app', debug=True, reload=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment