Great instructional style. Fast, Clear and Easy to Follow. “Just the right level of information” for even a beginner! Not to mention your fantastic dialect!
Thank you Tim! You're correct of course - it'd be much better to display that feedback rather than just outputting to the console. Should've added that!
Hi there! I hope you're doing well. I really like your recent videos on fast api and found it really informative . this video in with react is very helpfull. I am using django-rest-framework for building api but I really like fast-api . the only reason that prevent me from using it is the complex relationship between models and the ORM compare to django . However, I was wondering if you could create a follow-up video specifically delving into the complexities of FastAPI ORM relationships between models. As a viewer, I think it would be incredibly valuable to see an in-depth explanation of how FastAPI ORM handles more complex relationships and how it compares to Django ORM in those scenarios. I believe this would be particularly helpful for developers who are considering using FastAPI ORM but may be unsure about its capabilities in this regard. Thank you for your time and consideration, and I look forward to seeing more great content from your channel!
Thanks for this - appreciate it! FastAPI doesn't really have a built-in ORM like Django. However there's some tools that can be used - SQLAlchemy, SQLModel, TortoiseORM, etc. I will try and do some videos on these soon. I actually have a Django ORM series that I'll start releasing in the next few weeks, so after this, I'll try and incorporate some comparisons to these FastAPI database options.
@BugBytes I'd definitely be interested. I built a business using your Htmx-django series, but it's gotten to the point where the UI needs something more like react. With your style of teaching, it wouldn't feel as daunting a mission.
@@Septumsempra8818 I'll consider this, thanks for that. I have something on Django + Svelte in the works, but no doubt React is the big player among those SPA tools.
Good question. I've used Flask a lot in the past and it's an excellent tool. These days, though, I prefer FastAPI. I just love the Pydantic models that underpin FastAPI. It's also async-ready, unlike Flask. Both great frameworks though - nothing wrong with Flask at all!
Рік тому
This is the first time I see that a function's typing changes it's behavior
Hi BugBytes! I have a question. Would it be possible to use a function rather than a constant to upload the file to the FastAPI server? I'm trying to do it, but it's giving me an error 422 (Unprocessable Entity). Any help?
I'm trying to upload multiple files and I'm getting 422 unprocessable entity. The type in my endpoint is a list[UploadFile] and I'm iterating over the list of files like in your example, and the key in FormData is the same as the FastAPI endpoint parameter. Any pointers on what else I should check?
initially i also face same error, but resolve by making same variable name for files in react and fast api, the variable name "file" should be same.. -------------in FASTAPI---------- @app.post("/uploadfile/",status_code=201) async def upload(file: list[UploadFile]): print("files", file) for fi in file: data = await fi.read() save_to = UPLOAD_DIR/fi.filename with open(save_to,'wb') as f: f.write(data)
return {"filenames": f"Successfully uploaded {[fi.filename for fi in file]}"} -------------in react-------------- const formData = new FormData() files.forEach(file=>{ formData.append('file', file) })
It is honestly beyond me why frameworks like React and the use of SPA are still such a big thing / in demand on the job market. For 98% of use cases an SPA is an overkill, imho. It requires more and complicated code. There is duplication of code and logic on backend and frontend (in different programming languages). Also, managing of state is a pain. Django + htmx and / or alpine.js every day over this. And I hope that is where the web is moving.
I do agree with most of the points you've made. React has a place for apps involving a lot of stateful interactions, but I would say it's overkill for most projects. As you know, the HTMX/Alpine approach is my personal preference, but the reality is that React is still dominant in the market. Maybe that'll change soon...?
Again, awesome! No water, no fancy techniques, just what I needed to know to get started!
Thanks a lot!
Great instructional style. Fast, Clear and Easy to Follow. “Just the right level of information” for even a beginner! Not to mention your fantastic dialect!
Haha I'm always hoping the dialect (Glaswegian) is easily understood for most viewers 😄Thank you for the nice words!
thanks alot for the tutorial. For good measures it would be nice to display a message on the frontend on fail or success.
Thank you Tim! You're correct of course - it'd be much better to display that feedback rather than just outputting to the console. Should've added that!
Hi there! I hope you're doing well. I really like your recent videos on fast api and found it really informative . this video in with react is very helpfull. I am using django-rest-framework for building api but I really like fast-api . the only reason that prevent me from using it is the complex relationship between models and the ORM compare to django . However, I was wondering if you could create a follow-up video specifically delving into the complexities of FastAPI ORM relationships between models.
As a viewer, I think it would be incredibly valuable to see an in-depth explanation of how FastAPI ORM handles more complex relationships and how it compares to Django ORM in those scenarios. I believe this would be particularly helpful for developers who are considering using FastAPI ORM but may be unsure about its capabilities in this regard.
Thank you for your time and consideration, and I look forward to seeing more great content from your channel!
Thanks for this - appreciate it!
FastAPI doesn't really have a built-in ORM like Django. However there's some tools that can be used - SQLAlchemy, SQLModel, TortoiseORM, etc.
I will try and do some videos on these soon. I actually have a Django ORM series that I'll start releasing in the next few weeks, so after this, I'll try and incorporate some comparisons to these FastAPI database options.
A future video I would love to see would be: How to track page views per session, possibly with HTMX. Thank you! Truly excelent instructions as usual.
Thanks a lot Zack! Interesting suggestion, I'll look into it!
Absolutely amazing tutorial! It was super informative and you've a great job of explaining each step. Thank you so much for your help 😀
Thanks a lot for the kind words, really glad it helped!
Can you please share full source ?
thanks, great stuff
Thanks a lot for watching!
Are we gonna get a react django/fastAPI series?
I would like to do it if there's enough interest -- would it be something you'd like to see?
@BugBytes I'd definitely be interested. I built a business using your Htmx-django series, but it's gotten to the point where the UI needs something more like react. With your style of teaching, it wouldn't feel as daunting a mission.
@@Septumsempra8818 I'll consider this, thanks for that. I have something on Django + Svelte in the works, but no doubt React is the big player among those SPA tools.
@@bugbytes3923 yes, pls
Do you like Flask more or fastapi?
Good question. I've used Flask a lot in the past and it's an excellent tool.
These days, though, I prefer FastAPI. I just love the Pydantic models that underpin FastAPI. It's also async-ready, unlike Flask.
Both great frameworks though - nothing wrong with Flask at all!
This is the first time I see that a function's typing changes it's behavior
Hi BugBytes! I have a question. Would it be possible to use a function rather than a constant to upload the file to the FastAPI server? I'm trying to do it, but it's giving me an error 422 (Unprocessable Entity). Any help?
did you get any solution for this priblem
yes I am also getting same error
@@yashgajewar9019 make sure you used File instead of Files
where is the source code broo
I'm trying to upload multiple files and I'm getting 422 unprocessable entity. The type in my endpoint is a list[UploadFile] and I'm iterating over the list of files like in your example, and the key in FormData is the same as the FastAPI endpoint parameter. Any pointers on what else I should check?
paste here your FileForm.js
initially i also face same error, but resolve by making same variable name for files in react and fast api, the variable name "file" should be same..
-------------in FASTAPI----------
@app.post("/uploadfile/",status_code=201)
async def upload(file: list[UploadFile]):
print("files", file)
for fi in file:
data = await fi.read()
save_to = UPLOAD_DIR/fi.filename
with open(save_to,'wb') as f:
f.write(data)
return {"filenames": f"Successfully uploaded {[fi.filename for fi in file]}"}
-------------in react--------------
const formData = new FormData()
files.forEach(file=>{
formData.append('file', file)
})
Thank u for all the fastapi videos!!!
Thanks a lot!
It is honestly beyond me why frameworks like React and the use of SPA are still such a big thing / in demand on the job market. For 98% of use cases an SPA is an overkill, imho. It requires more and complicated code. There is duplication of code and logic on backend and frontend (in different programming languages). Also, managing of state is a pain. Django + htmx and / or alpine.js every day over this. And I hope that is where the web is moving.
I do agree with most of the points you've made. React has a place for apps involving a lot of stateful interactions, but I would say it's overkill for most projects. As you know, the HTMX/Alpine approach is my personal preference, but the reality is that React is still dominant in the market.
Maybe that'll change soon...?
UA-cam should ban all the youtuber who does not put the source code