Build a Rest API with Django Rest Framework
Vložit
- čas přidán 2. 06. 2024
- This is a Django crash course that will help you build a REST API
Github Repo:
github.com/harblaith7/Django-...
Timeline:
0:00 - Intro to Django
4:00 - Models
8:30 - Views
12:30 - Urls
18:00 - Migrations
20:45 - Serializers
51:18 - Class View
1:03:30 - Model Serializer
I LOVE how you spent most of the tutorial showing the explicit but repetitive way of doing it. What makes me stuck with Django REST Framework is that there is too much "magic" going on. It's so important to see how it works in details when we're not using ModelSerializers or other magic classes.
This was a really good, concise and accurate course. Thanks!
Best explanation on Django API I have come across on CZcams. Thanks for sharing
Am a frontend developer, but just started backend (django) late last month. I must confess this is the third video tutorial have gone through on CZcams on Django, but this very one is top notch. Thanks for sharing.
I will be glad if you can also share authentications (register and login) as well. Thanks a bunch
This is my first video on this channel..subscribed to your channel. What an underrated channel!! You deserve millions of subscribers. I am going to watch your videos..
was struggling to undertand django after buying a course, if only i had seen this video, loved the detailed explanation, great job
This is a great tutorial.. I was looking for a quick tutorial and this one is just right.
you explain every things very well. after tried lots of premium and youtube docker tutorial, finally your docker crash course make things easy for me. Please make a nodejs microservices tutorial with kafka if possible.best wishes
Great tutorial as always!!!
love the way you teach. So calm and easy. Even if my native language isn't english, I can fully understand you. Love from Pakistan.
Thanks a lot for the amazing course!
you make it really simple! thank you so much
good job i search django tutorial in youtube and your tutorial very clearly for me thanks
👌
Any chance you’d be able to please make a react pagination video, where the data is coming from an api but also include a search bar in the same project?
Excellent tutorial, very thanks
thanks for the tutorial. it was very helpful.
Thank you for this video! It was awesome =]
Awesome video, thanks so much.
Very helpful thanks a lot !
Great tutorial!
I like this, very clear
subscribed sir..wont say much..but u cleared everything thank you.
Great tutorial
Very helpful for a beginner. Please do authentications and authorizations too. Needed urgently
OMG! Thanks so much!
Hi, what if i want to update only one field? For example I want to update description of id "1"???
I will be glad if you can also share authentications (register and login) as well. Thanks a bunch
On next video, try to do Web3, Blockchain course
Nice tutorial.
Please what about authentications
thank u very much
thank you, everything you have done happens in the api. what about the real app?. consider someone who already has a django app, and they want to create an api to tinker with it. what changes can they make on this your code
need more django tutorial such as auth
awesome
When should I use viewsets instead of views?
Thanks
Hello, working with the get by pk function does not work when the id is not in the database, it returns an atribute error page
The get_book_by_pk function returns the error response to the get function, instead make the get function return the error response.
class putpostdelete(APIView):
def get_book(self,pk):
try:
book = Book.objects.get(pk=pk)
return book
except:
return 1
# return Response({
# "Error":"Book does not exist"
# },status=status.HTTP_404_NOT_FOUND)
def get(self,request,pk):
book=self.get_book(pk)
if book==1:
return Response({
"Error":"Book does not exist"
},status=status.HTTP_404_NOT_FOUND)
Smoething like this.
can you write e-commerce use django all fremwork(rest_api,auth,static_file ,templates,users,)
Thank you so much for the amazing content 👍🙏🤝👋🫡👌🫶🏻✌️👏🏻😎👌🫶🏻
Your repo does not have the code pushed. main branch only without any of your code.
Can we have the Source code for reference?
From where is the create() method (at this timestamp: czcams.com/video/mlr9BF4JomE/video.html) in the Book model called? I didn't see it anywhere in the code.
the code is not available in the repo. can you update it.
this api working for integrating in flutter
lol you r the goat
Integration of Chrome extension and api calls plase
code ? коде ?
This video is so hard to follow. Immediately after typing new code, you switch to a different file, so the viewer has to rewind the video if they didn't type everything that you just typed, down to the second. When you refactor, why are you doing that? What are the benefits and disadvantages? After we refactor using APIView, your justification is "I like that a whole lot better." These aren't legos or a painting of a lake, it's logical code and knowing the WHY matters a ton, especially if we're refactoring something for the third time.
If you pass a wrong id while fetching against id it will trough an error. It will not work with get_by_pk function if but If your try this method it will work perfectly because it's returning from the above function and after it will be inside get function to try this method. Thanks
def get(self, request, pk):
try:
book = Book.objects.get(pk=pk)
serializer = BookSerializer(book)
return Response(serializer.data)
except:
return Response({
'error': 'Book does not exist'
}, status=status.HTTP_400_BAD_REQUEST)
Thank you! Was wondering what was wrong with my code, but this helped.
For those who are confuzed about why the PUT mehtod acting like a POST in the section of "Class View"
One return is missed in the demostration, it should be like this(I have my own variation repalced book with picture):
def get_picture_by_pk(self,pk):
try:
picture = Picture.objects.get(pk=pk)
return picture
except:
return Response({"Error":"picture not found"},status=status.HTTP_404_NOT_FOUND)
Very helpful thanks a lot !