Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ“ Add link to article in Russian "FastAPI: знакомимся с Ρ„Ρ€Π΅ΠΉΠΌΠ²ΠΎΡ€ΠΊΠΎΠΌ" #2564

Merged
merged 2 commits into from May 6, 2021

Conversation

trkohler
Copy link
Contributor

Hi there! πŸ‘‹

Hope it would be considered as useful addition!

In my article in Russian I covered how to:

  • get familiar with FastAPI framework
  • set up tests
  • connect to async Tortoise ORM
  • make async test for the previous feature

Sorry in advance for the ugly link :( Gatsby generates it based on Russian headline and I still hadn't fix this.

@codecov
Copy link

codecov bot commented Dec 23, 2020

Codecov Report

Merging #2564 (3ebf691) into master (e6f8aa8) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #2564   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          242       243    +1     
  Lines         7396      7419   +23     
=========================================
+ Hits          7396      7419   +23     
Impacted Files Coverage Ξ”
fastapi/routing.py 100.00% <0.00%> (ΓΈ)
fastapi/encoders.py 100.00% <0.00%> (ΓΈ)
fastapi/concurrency.py 100.00% <0.00%> (ΓΈ)
fastapi/applications.py 100.00% <0.00%> (ΓΈ)
fastapi/openapi/utils.py 100.00% <0.00%> (ΓΈ)
fastapi/datastructures.py 100.00% <0.00%> (ΓΈ)
tests/test_params_repr.py 100.00% <0.00%> (ΓΈ)
fastapi/security/__init__.py 100.00% <0.00%> (ΓΈ)
fastapi/dependencies/utils.py 100.00% <0.00%> (ΓΈ)
tests/test_custom_route_class.py 100.00% <0.00%> (ΓΈ)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update d6b5bc9...3ebf691. Read the comment docs.

@github-actions
Copy link
Contributor

πŸ“ Docs preview for commit e7edcd9 at: https://5fe3307954191c47747c60ae--fastapi.netlify.app

Copy link
Contributor

@ArcLightSlavik ArcLightSlavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Screenshots for postman aren't loading

Screenshot 2020-12-23 at 23 40 35

  1. Think the link should be just renamed to an english one.

  2. I severely disapprove the usage of response_model_exclude=["password"], # new !, you can get the same result by splitting your pydantic models, example: https://fastapi.tiangolo.com/tutorial/sql-databases/.

@trkohler
Copy link
Contributor Author

Thank you for noticing @ArcLightSlavik seems like I fixed images from postman and slugs -- the whole time I thought it requires much more work than it actually was.

on third point I'll change that according to recommendation, but wondering why? Making separate in and out models and also separate ORM Model seems like a tons of code repeating almost the same thing every time. Is there any way to avoid this?

@ArcLightSlavik
Copy link
Contributor

Your confusing orm model and pydantic model. Orm model should include every single field in a table, but you wouldn't want to return every piece of information in the response all the time, this is where pydantic comes in.
Say you have 100 fields in your table but you only want to return 2, your response_model_exclude would have to include every field in there and then it would be repeated for any other endpoint you might make(!). By making multiple pydantic models you don't have to duplicate it. For me response_model_exclude is more of only **this** endpoint doesn't need this field.

In tortoise it would be something like this? (pseudo code)

SoftwareEngineer_Pydantic = pydantic_model_creator(
    SoftwareEngineers, name="SoftwareEngineer"
)
SoftwareEngineer_Out_Pydantic = pydantic_model_creator(
    SoftwareEngineers, name="SoftwareEngineerOut", exclude=('password')
)

https://github.com/tortoise/tortoise-orm/blob/develop/tortoise/contrib/pydantic/creator.py#L117

@tiangolo
Copy link
Owner

tiangolo commented Feb 7, 2021

Thanks for the help and suggestions @ArcLightSlavik !

Thanks for the article @trkohler ! πŸ€“

Nevertheless, when I try to access it I'm getting a 404. Maybe you updated the URL?

@trkohler
Copy link
Contributor Author

trkohler commented Feb 7, 2021

yes, I have and forgot about it :(
Let me update the url in PR!

While I'm in process, this is a new url which should work

@trkohler
Copy link
Contributor Author

trkohler commented Feb 8, 2021

I fixed the link in PR, should work correctly now

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2021

πŸ“ Docs preview for commit 3ebf691 at: https://6020e8e15f91d4b2287bcb2e--fastapi.netlify.app

@tiangolo tiangolo changed the title Adding link to article in Russian πŸ“ Add link to article in Russian "FastAPI: знакомимся с Ρ„Ρ€Π΅ΠΉΠΌΠ²ΠΎΡ€ΠΊΠΎΠΌ" May 6, 2021
@tiangolo tiangolo merged commit 73d1def into tiangolo:master May 6, 2021
@tiangolo
Copy link
Owner

tiangolo commented May 6, 2021

Great, thanks! β˜•

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants