-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project?Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝 Add documentation on how to use the Django ORM inside FastAPI #11782
base: master
Are you sure you want to change the base?
Conversation
patrick91
commented
Jul 1, 2024
- Add initial documentation for using the Django ORM
- Add async example
📝 Docs preview for commit1b83a5dat:https://89c6eacf.fastapitiangolo.pages.dev |
📝 Docs preview for commit85ea9aeat:https://70478e6c.fastapitiangolo.pages.dev |
📝 Docs preview for commit5909e93at:https://1421e46e.fastapitiangolo.pages.dev |
📝 Docs preview for commite639870at:https://cbdcbcd0.fastapitiangolo.pages.dev |
📝 Docs preview for commit048a762at:https://5ee78811.fastapitiangolo.pages.dev |
048a762
to
63212e6
Compare
📝 Docs preview for commit3768b3cat:https://3f3e5c23.fastapitiangolo.pages.dev |
📝 Docs preview for commitd259c13at:https://ee45910f.fastapitiangolo.pages.dev |
📝 Docs preview for commit5e49b3fat:https://1fc2129e.fastapitiangolo.pages.dev |
I think it would be better to move this guide to "How To - Recipes" section. Also, using global object to access DB session is not a good practice. It should be at least moved to dependency to allow it to be overridden in tests. Overall, I like the manner of presentation, and I find this guide useful. |
📝 Docs preview for commitd09df4bat:https://8f837f99.fastapitiangolo.pages.dev Modified Pages |
📝 Docs preview for commit0daa2a6at:https://a746d109.fastapitiangolo.pages.dev Modified Pages |
📝 Docs preview for commita41a165at:https://f524fd2c.fastapitiangolo.pages.dev Modified Pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is a nice addition to the docs 🎉
I've gone ahead and fixed the code examples which are marked up slightly differently since a recent PR tomaster
.It looks good on the preview now. Otherwise only a few small comments/suggestions 🙂
Django's support for async is currently limited, if you need to do run any query in an async route (or function), | ||
you need to either use the async equivalent of the query or use `sync_to_async` from `asgiref.sync` to run the query: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Django's support for async is currently limited,ifyou need todorun any query in an async route (or function), | |
you need to either use the async equivalent of the query or use`sync_to_async`from`asgiref.sync`to run the query: | |
Django's support for async is currently limited.Ifyou need to run any query in an async route (or function), | |
you need to either use the async equivalent of the query or use`sync_to_async`from`asgiref.sync`to run the query: |
|
||
HERE = pathlib.Path(__file__).parent | ||
|
||
sys.path.append(str(HERE.parents[2] / "docs_src" / "django_orm" )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm usually wary of messing withsys.path
,is this the only way to make this work?
```Python | ||
{!>../../../docs_src/django_orm/tutorial001.py[ln:23-37]!} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would it make sense to include the full code fromtutorial001.py
somewhere at the end, to make it even easier on the reader to replicate all this?