Django & React Tutorial #2 - Django REST Framework
Вставка
- Опубліковано 8 лис 2020
- This django and react tutorial covers how to use the django rest framework. We will use the django rest framework to implement a django REST API and setup some endpoints to use later in our project.
💻 AlgoExpert is the coding interview prep platform that I used to ace my Microsoft and Shopify interviews. Check it out and get a discount on the platform using the code "techwithtim" algoexpert.io/techwithtim
📚 Django Model Documentation: docs.djangoproject.com/en/3.1...
📝 Series Code: github.com/techwithtim/Music-...
📕 Node.js & NPM: www.npmjs.com/get-npm
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
💰 Courses & Merch 💰
💻 The Fundamentals of Programming w/ Python: tech-with-tim.teachable.com/p...
👕 Merchandise: teespring.com/stores/tech-wit...
🔗 Social Medias 🔗
📸 Instagram: / tech_with_tim
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
🌎 Website: techwithtim.net
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
🎬 My UA-cam Gear 🎬
🎥 Main Camera (EOS Canon 90D): amzn.to/3cY23y9
🎥 Secondary Camera (Panasonic Lumix G7): amzn.to/3fl2iEV
📹 Main Lens (EFS 24mm f/2.8): amzn.to/2Yuol5r
🕹 Tripod: amzn.to/3hpSprv
🎤 Main Microphone (Rode NT1): amzn.to/2HrZxXc
🎤 Secondary Microphone (Synco Wireless Lapel System): amzn.to/3e07Swl
🎤 Third Microphone (Rode NTG4+): amzn.to/3oi0v8Z
☀️ Lights: amzn.to/2ApeiXr
⌨ Keyboard (Daskeyboard 4Q): amzn.to/2YpN5vm
🖱 Mouse (Logitech MX Master): amzn.to/2HsmRDN
📸 Webcam (Logitech 1080p Pro): amzn.to/2B2IXcQ
📢 Speaker (Beats Pill): amzn.to/2XYc5ef
🎧 Headphones (Bose Quiet Comfort 35): amzn.to/2MWbl3e
🌞 Lamp (BenQ E-reading Lamp): amzn.to/3e0UCr8
🌞 Secondary Lamp (BenQ Screenbar Plus): amzn.to/30Dtafi
💻 Monitor (BenQ EX2780Q): amzn.to/2HsmUPZ
💻 Monitor (LG Ultrawide 34WN750): amzn.to/3dSD7tS
🎙 Mic Boom Arm (Rode PSA 1): amzn.to/30EZw9m
🎚 Audio Interface (Focusrite Scarlet 4i4): amzn.to/2TjXsih
💸 Donations 💸
💵 One-Time Donations: www.paypal.com/donate?hosted_...
💰 Patreon: / techwithtim
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
⭐️ Tags ⭐️
- Tech With Tim
- Django and React
- Python Django
- Javascript React
- Django and React Tutorial
- React and Django Project
- Django REST Framework
- Django REST API
- REST API Django
- REST API
⭐️ Hashtags ⭐️
#Django #React #JavaScript
I actually gave myself a pat on the back like Tim told us to. :)
Hi Tim, thanks so much for this tutorial. It covers a whole lot about React and Django! Really helpful!
I have been through many react and django courses. But you are the best by far. Easy explanations and clean coding style. Hats off to you man!
yeah he is good
I tried learning python's django a lot of time and got to understand nothing, so left everytime... But learnt react js and mastered it! Now i am not gonna leave this anytime and apply it to my react js and react native applications ! Thanks a lot needed indeed!
These videos are fantastic. Thank you!
Super helpful! Thank you for this series!
I love this series!! pls do more web apps with python & javascript!
Loving the serie! 🚀
This video is pure gold, even 2 years after it was created.
Thank you so much!
Bro please help me with react routing system because the one used in the video is outdatet how do i fix it it shows nothing on my page
Clear, concise, the audio is high quality,
Thx Tim really cool! Love your vids
6:08
tim: thats what django was trying to tell us to do
captions: thats what jane was trying to tell us to do
@Kelvin Jack are you guys the same people behind the InstaPwn scam, there's always two people involved
Awesome tutorial!
Excellent video Tim love your content keep going bro
The "pylint Path" killed me for like an hour!
This was helpful to me stackoverflow.com/questions/62473201/how-do-i-enable-pylint-in-vscode
Thank you. thank you. thank you. keep going
This is sooo helpful Tim! I'm literally crying right now bc you solved my problems 💮
greate job sir thanks
these videos are the best
i wonder Why would anybody dislike this video? Thanks Tim for this tutorial
for sure by mistake
Nice job !
small change as of AUG 2023, it is now required to explicitly state all fields of the associated model will be included in the serializer with `fields = '__all__'`
i liked this video it's my first time using rest framework thanks
Cool video!
Finally please keep going. Love your tutorials bro
That’s lit 🔥 man keep going
Uh 😒 what do u mean rayaan
🔥 lit means cool and fire
Your tutorials are getting better every day, congratulations man, You have an awesome yt channel :D
Veryu good thank you!
Room.objects.filter(code=code).exists() is a method specifically designed to check if it exists or not.
In your serializer, you can also do; fields = ‘__all__’
Cool video series btw!
can you please explain it more ? please write a full code
@@behjaf Well, the way Tim is checking if a room exists (when creating a random code), he does: Room.objects.filter(code=code).count() == 0. While the django way would be: if not Room.objects.filter(code=code).exists()
And for the second thing, he enters fields one by one now. While if you want all fields to be used, you can do fields = “__all__” instead.
@@JoeyJurjens thank you Joey😇
@Shifa Shaikh misspell at max_length
Phew! Thanks man. I had a hard time getting this.
Damn, got to video 2 and realized they are only just now getting released.... Will be keen to watch the rest.
This is a very good tutorial, very straight forward.
yes really detailed
thanks a lot
I love that these are sponsored by AlgoExpert. You and Clement are my goals :D
Awesome tutorials Tim, keep 'em coming! Regards from Brazil!
Hey man! Brazil here as well! I'm trying to learn how to code, it has been a Journey full of challenges but I'll get there!
best video brother.
Your tutorials are always perfect and include everything I want to learn and need. Just a very big thankyou again!!!❤️
i just finished the part 1....and you uploaded the part 2....i thought i have to wait for it ....but its here now ....thanks bro
Instead of mentioning all the fields (one by one) in Meta class, you can simply put fields = '__all__'
Thanks man saved me a lot a time
Could that been done this way by purpose? Maybe he will move some of the fields under the variable of read_only_fields in the future so it will be easier to just cut and paste those.
Didn't he list them all because he wanted to have the possibility of adding a custom 'id' one ?
@@KopfKino901 No even if he used '__all__' the id will be added too
are you serious?
Love you😍😍😍
Thanks Tim! You are the best!
Again huge thanks for this. I wish you could do longer videos. I know you must be pretty busy.. but still 20 min every 2 or 3 days is so short :( Love the content
so true
Thank's tim ..... ! ..... your video's are really helpful
it would be better if u can explain serializer and rest framework.
thanks for the great videos Tim
thanks
Keep your awesome
dope i hope it will be daily:D
tim the 🐐
Cool.
Hey Tim, I just want to thank you again for making these videos. I watched almost all of your videos and learned various programming concepts from you. Keep up your good work on your youtube channel. You deserve at least 1 million subscribers.
You're very welcome!
As someone who has been binging React builds recently but is better at Python (for vanilla coding, Python > Vanilla JavaScript), this series is PERFECT for me!!! Keep up the good work Tim!
Yay!
Hello Tim
Some things I want to learn are :
1. Logging System with 2 views administrator privileges and Customer privilages.
2. Upload Image for example change profile picture.
Thanks
Ankit Rusia
Use roles or groups for Logging System with 2 views administrator privileges and Customer privilages..
Really nice video Tim.
It will be interesting seeing a GraphQL REST API
I think "fat models and thin views" does not mean put the logic, but put, in models, helper method for the controller to make logic thinner.
smart suggestion
Amazing tutorials as always Tim! I have been subscribed for a year now and have learnt so much from you! Thank you for these videos
Appriciate you videos Tim! Can your next Time out with Tim be with thenewboston since Bucky's back? Thanks.
I second this! I got started on Bucky!
here!
It came in the perfect time
Done.
was waiting for it thanks how are you doing
First like, sir! Was waiting extremely eagerly for the 2nd part😀😀❤️🔥🙏
Aaaahhhhh stop using those emojis REEEEEEEEEEEEEEE
@@rdius4822 sorry bro, can't stop me😁
@@aishikbandyopadhyay8191 you're using them excessively...
I haven't been able to makemigrations successfully after creating the model Room.. Each time i run the commands at 9:23 it gives me the output:
No changes detected
Have tried deleting my migrations and doing again as suggested elsewhere, but this does not seem to fix the problem.. Any help or suggestions are appreciated..
EDIT : I managed to fix the issue.. For anyone else who had this same issue and got OperationalError later, try making an empty folder named migrations in the api folder and then make an empty __init__.py file and then try makemigrations, migrate and finally runserver..
usualli it happens bd you forget to add your app in settings of your project
Thank You so much, this is exactly what happened to me and it worked
@@user-se7yq6cl2j Thank you so much, I got stuck with this a lot
Most of students having a doubt that, Did we stick to just one programming language or learning multiple languages helps us in the future.With python what types of jobs can I'm able to apply.If you do a video about this that would be really helpful.
My advice is learning at least two languages of higher level and then learn a lower level language. This will give you a good understanding of computer science in my humble opinion.
More related to the topic of this video python django and javascript react are a a amazing combo to make websites and web apps. But i would also recommend trying the mern stack(mongo db- no sql database; express - javascript backend framework; react; n - nodejs - javascript runtime to run javascript outside the browser). Or a more enterprise stack is java swing for the backend and angular(javascript framework similiar to react(@ben awad please dont kill me)).
@@migueldomingos4570 Thank you very much sir, for spending your valuable time for me ♥️.
@@gladsonsebastian4464 You are welcome and good luck with your UA-cam journey
please make projects on Shipping management system in django
@Tim I had Codeium autocomplete on (similar to Tabnine or Github Copilot) and after a few lines it started predicting every block I was about to type with 100% accuracy.
That means your code is in the GPT (I am pretty certain Codeium is GPT powered) database. Congratulations Tim?! Or sorry? Not sure...
100th like 💯...
12:28 you can just type "__all__" to avoid typing out all the fields manually if i am not mistaken
honestly before this tutorial i used php laravel which is similar but the syntax of php is disgusting im looking to switch to python django thank you tim like always
Hi Tim! Thank you for this great tutorial!
Just curious, any reasons why you mentioned in 5:58 that models should be 'fat' and views should be 'thin'? My current practice is keeping the heavy logic in the views rather than models.
I was also surprised by this and would like to know more about that reasoning.
same
I believe its to keep functionality that is related to data as close to that data as possible, instead of spread out
When you generate unique code do you not have to call the function or will it just run by default?
We can use uuid to generate unique token for the room we just have to redfine the init function to call the function how handle this
❤️
Can someone help me pleas. I keep getting an error in the models.py file. The error is referring to the if statement in the generate_unique_code() funtion at 8:58. invalid syntax (, line 15) pylint(syntax-error) [15,56]
I believe the issue is that he is using an assignment operator "=", when he should be using a comparison operator "==".
So the code should read: if Room.objects.filter(code==code).count() == 0:
@@austonlarson6563 This solved the problem. Thanks a lot!!
Not sure about fat models, thin views
I think MVC (Model-View-Controller) pattern would be better in most of situations
p.s. tutorial is amazing as always, keep it up Tim!
So put all business logic to the services.py for example
Nice Tutorial Tim, keep going with this series.
Can I use rest_framework and serializers also with angular?
Thanks.
Sure. You just need an API made with any backend framework and then JavaScript in the front-end can call that API using something like fetch or a more framework specific fetching library. And yes angular has JSON serializers since it is a built-in feature into JavaScript itself
can someone help me? I'm getting a no such column error page when I post in Room
idk if I'm late , but i think the problem here is in the serializers file in fields u may have a error of copying :)
Hey, When you're done add the whole tutorial to a playlist. Thanks. Really Good Work!
Great series but i am having a problem with the following error: "detail": "Method \"GET\" not allowed." I tried changing the setting and searched how to allow it run a get request... still need to do more searching.
I am getting this error message:
Traceback (most recent call last):
File "c:/Users/Vinu/Downloads/React-Django/music_controller/api/serializers.py", line 2, in
from .models import Room
ImportError: attempted relative import with no known parent package
I have a problem when i try to makemigration, it shows me this message :
type object 'Room' has no attribute 'object'
I had the same issue, but was able to fix it by doing the following:
1. Go to terminal and enter pip install pylint-django
2. Installing the pylint extension on VS Code
3. In VS Code going to Settings > User Settings and in searching through search bar for "Linting: Pylint Path" and then changing the path from pylint to pylint_django
If this doesn't solve your issue, I recommend trying out the other new solutions on this stackoverflow thread : stackoverflow.com/questions/45135263/class-has-no-objects-member
Really hope this helps in solving your issue..
@@lyteral7 thank you so much !
you just have to change your "Room.object" to "Room.objects" and it'll link it to .models automatically
@@lyteral7 unable to perform step 2. cannot find pylint extension on vscode
@@rishbizzbuzz Make sure your python path is set properly in vscode
Try some of the newer answers here:
stackoverflow.com/questions/43272664/linter-pylint-is-not-installed
when am going to the room view. if if I do api/home. it does not work. but when I write just /home, then I get the view
As i am saving my settings.py, it is showing me an error and is not producing any link after i am running the command 'python manage.py runserver' to connect to server. Why is it so ?
Thank you
Hey Tim, excellent video, just had one single problem i.e I didn't get the form to input data into the db although I followed the exact same steps and even tried cloning the git repository for the particular tutorial, please help.
facing the same issue
please help me with react routing system because the one used in the video is outdatet how do i fix it it shows nothing on my page
why do we need to add code and host to model?Like I have learned sql but I wouldnt add it to models? Somebody explain
I am getting an Error in 16:30 Can anyone please help me???
Error As :-
'TodoView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method.
Template does not exist at api/home...
please help
Will you be deploying it too?
Which font do you use in vs code?
getting this error after i try to post "OperationalError at /api/home
no such column: api_room.code"
*EDIT in the models host needed to have a default of none
host = models.CharField(max_length=50, unique=True, default=None,)
Ok, guys help me out here, if I learn Django, React and Mongoose do I become full-stack. If no then what do I gotta do?
That should be good.. You can also learn about web hosting and other stuff
Trying to make migrations at about 15:20 but getting an error of ModuleNotFoundError: No module named 'api.serlializer'. Anyone else getting this error or know what the fix might be?
same error here, sadly no answer
when I remove the main def in views I get Import Error: cannot import name 'main' from 'api.views' any ideas how to fix?
Its soo good.but without generate_unique_code(): in model also its working fine; where you used this.
I’m noticing if you’re python3 you can’t put a .before the path. Is my assessment correct ???
I guess if you pass the default value, in that case, you don't have to mention the null argument.
At 9:10 for it to break when the code matches, I think it should be != instead of ==
He is correct. Check it again
how to fix?
ImportError: cannot import name 'RoomSerializar' from 'api.serializers' (C:\Users\dell\Favorites\Desktop\python and js\music_controller\api\serializers.py)
how to fix?
I want full Django + Ajax + frontend ecommerce tutorial! There are some tutorials out there but they do not teach you things like adding items to cart without reloading page, item stock count, search bar etc.
I can not figure out why the feildset for the form is not present in my view.... maybe one of the methods is deprecated? I would think that would create an error... any pointers. FYI I like getting errors like this because debugging is such a great way to learn..... when you can actually figure it out lol