thanku so much this is what i actually looking for and did not find it anywhere
@codeenvironment4 жыл бұрын
Thanks Ajeet, please check the Django REST Framework playlist , I’m sure you will find a lot to learn from : kzbin.info/aero/PLmDLs7JbXWNjr5vyJhfGu69sowgIUl8z5
@LakshmanKumar-qp9xn4 жыл бұрын
Hey Ajeet Mishra.. Let me know how to write create methods in views..Table occurred 4 foreign keys... Please suggest me..
@codeenvironment4 жыл бұрын
@@LakshmanKumar-qp9xn please watch the overriding create action tutorial for that : kzbin.info/www/bejne/apWzh6yti5KLbpY
@quangtranvan96062 жыл бұрын
Very convenient, thank you very much
@josiahdavid77353 жыл бұрын
I'm loving this guy more and more
@amirhosseinebneroomi72804 жыл бұрын
good job man. I like your teaching style.
@codeenvironment4 жыл бұрын
Thank you Amir 👍🏻
@sofistoyanova71214 жыл бұрын
Exactly what I was looking for. Thank you so much!!
@codeenvironment4 жыл бұрын
Glad I could help!
@danieldimitrov70673 жыл бұрын
Very useful info on Django, great work!
@sagargahatraj51963 жыл бұрын
Thanks alot bro i was stuck almost three days and got burned out because of unknow about depth = 1 😭Thanks alot♥♥
@codeenvironment3 жыл бұрын
Glad I could help 🙂👍🏻
@aalekhmotani38773 жыл бұрын
me too thanks a lot code environment
@wirm95953 жыл бұрын
Hey Man, you've helped me out with this video. Thankyou, big time!
@codeenvironment3 жыл бұрын
I’m glad I could help ✌🏻
@frost1x3224 жыл бұрын
Great vids, I absolutely love it and think that it's best django tutorial on youtube. Yet, on small remark - you won't have to write all your model fields in serialization if you use *fields = '__all__'*
@codeenvironment4 жыл бұрын
Thank you Denis 🙂, and yes you are 100% right about the fields and to be honest, a few weeks ago I was thinking about the same thing, like why I keep writing the whole fields lol, but I still didn’t find a reason for that🤷🏻♂️, maybe I’m not lazy enough 😅
@chris.dillon4 жыл бұрын
I know that this isn’t the forum for this and beginners don’t need philosophy... but postman is a GUI for manual testing. It won’t scale. It won’t catch bugs. I use postman instead of a browser I guess but I try to get away from it. The problem is that books and tutorials don’t focus on automated testing which is going to do many positive things for a project. In all tutorials like this, there is some section where the teacher asserts that the output is correct with their human eyes. This is not needed. A computer can read JSON. You can teach it what “right” is. Measure it with a non human sensor like science. Then tools and culture would move that way and it would be less mysterious how to build stuff that works, can be refactored, does not have upgrade regressions or more things like this that testing touches on.
@codeenvironment4 жыл бұрын
Thanks Chris for sharing your thoughts, and I totally agree with you , therefore I’m preparing a tutorial for API testing. But for the purpose of understanding the basics, how relationships work and what the developers should expect to see as responses or how the request data should look like, postman comes really handy as keeping things simple helps beginners understand the concept.
@FullStackDevGreg3 жыл бұрын
depth = 1 mind blowing for me thanks
@codeenvironment3 жыл бұрын
I agree, it’s magical👌🏻
@shrutiagarwal143 жыл бұрын
Super awesome! Query: I am trying to retrieve the list (in this example, car plan) to angular input, can you share any reference material for the same?
@oscarparedez14173 жыл бұрын
Hi Code Environment. I've got a question: How can I tell my serializer to only display certain fields from the foreign key reference? In this case just returning car plan id and car plan name?
@codeenvironment3 жыл бұрын
You can use something called www.django-rest-framework.org/api-guide/relations/#custom-relational-fields
@roja78544 жыл бұрын
In apiview, am able to see all the details (including one toone related field details) but when I am trying to post the details there is no drop down field to set the other model object. I have included the all the fields including other model name in the serializer field attribute. Please help me on this
@codeenvironment4 жыл бұрын
Could please share the code with me at: Codes.environment@gmail.com
@NguyenQuangHieu-IIOIO3 жыл бұрын
what about one to many, how do i want the response to the carplan along with a list of the corresponding carspecs (sorry, my english is not good)
@n.e.pranavakumaar4470 Жыл бұрын
Hi sir. I have a issue here. For me it is getting displayed as car_plan = null whereas in your case the corresponding id is rendered. How to solve this?
@siddharthsrivastava44914 жыл бұрын
Plz anyone tell me this. This great but how can a user know that is id is for this plan while creating a new object.
@codeenvironment4 жыл бұрын
Sorry for the delay, I was sick. You don't have to use the plan's ID, you can simply use the plan name while creating a new object, but before that you need to edit the create function in the views.py file: just replace car_plan=CarPlan.objects.get(id=car_data["car_plan"]) with car_plan=CarPlan.objects.get(plan_name=car_data["car_plan"]). Thanks.
@ketankulkarni4273 жыл бұрын
@@codeenvironment and thanks a lot for the answer ! You are awesome.
@ketankulkarni4273 жыл бұрын
Nice question.
@anilkumarmandava11654 жыл бұрын
Hi.. this is helpful. Can you also explain how we can display CarSpec details inside each CarPlan. In other words how can we see list of different CarSpecs available under each CarPlan in API
@codeenvironment4 жыл бұрын
Thank you, one of the approaches is to add an extra field in the CarPlan serializer using a function that will get the CarSpecs objects related to the fetched CarPlan object. You can also use ManyToMany relationship in the CarPlan model to link multiple CarSpecs objects, see this video: kzbin.info/www/bejne/pHOUfpawfdGqm6M
@Travellife88774 жыл бұрын
osm video ........a big thumbs up
@codeenvironment4 жыл бұрын
Thank you :)
@dhanalm4 жыл бұрын
I have Author and Book models.In Book model, author is foreignkey. I want to display collection of books, for each author. So I have created property function in Author model and in Author serializer, I have added books in fields... But I'm only getting Book Id. I also want all fields of Book model. Please help me
@dhanalm4 жыл бұрын
I have also tried this books = BookSerializer(many=True) books is related_ name of author foreign key field in Book model
@codeenvironment4 жыл бұрын
Hello Dhana, can you please send me an email at: codes.environment@gmail.com Thanks
@dhanalm4 жыл бұрын
@@codeenvironment please check your inbox. Thank you
@vinsmokearifka4 жыл бұрын
Thank you
@shubhamshirbhate90684 жыл бұрын
hii.. when i use postman for post so it gave error 400bad request but i fallow you... so what i do.. for post request..
@codeenvironment4 жыл бұрын
Make sure all the parameters you are sending are named currently and make sure you have a forward slash / at the end of your url
@shubhamshirbhate90684 жыл бұрын
@@codeenvironment i try all the way still same
@codeenvironment4 жыл бұрын
Please email me at codes.environment@gmail.com, And I’ll have a look at your code
@ketankulkarni4273 жыл бұрын
How can i perform bulk update in Django Rest Framework ? Can you plz help me with it ?
@codeenvironment3 жыл бұрын
Can you please explain more to me what are you trying to achieve in bulk
@ketankulkarni4273 жыл бұрын
@@codeenvironment So I am fetching all the data from db against one table using Get api. Say there are multiple ids and 4 fields against each id. So for multiple ids, If user wants to update any of the field from any of the id, it should be done by bulk update. How should I achieve that ? I hope the scenario is clear to you.
@codeenvironment3 жыл бұрын
Let’s say you have multiple items and the user wants to update the price for 4 items then you can get all the objects: Items = Item.objects.all() Then loop through the objects and set the values for price field Item.price = new value And outside the for loop you can do the bulk update: ITem.objects.bulk_update(items, [“price”])
@ketankulkarni4273 жыл бұрын
@@codeenvironment thank you so much !!! It's helpful.
@dante7222 Жыл бұрын
Great tutorial tks. And if there are more than one car plan per car ? how can i setup the models ?
@amirhosseinebneroomi72804 жыл бұрын
I did the same thing I think, it gave me this error IntegrityError at /transactions/2 NOT NULL constraint failed: transactions_draft.office_id inside the draft object, there is an office object. and I want to create a new draft object. I pass the id of the office in the post request but it gives me this error
@codeenvironment4 жыл бұрын
Hello Amir, could you please send me the code at: codes.environment@gmail.com I’ll check it out and get back to you as soon as possible.
@chachacha12893 жыл бұрын
Very interesting though you are not focusing on the main subject of your video which title is 'Many To One Relationship'. And it remains a little bit unclear for me. Tell me if i am wrong: One CarPlan can have Many CarSpecs. but: One CarSpecs can only have One CarPlan. So should'nt it be a One to One relationship ? If I have a class Car and a class User. A User can have Many Cars. But One Car can only have One User. If I set a models.foreignKey(User, on_delete=SET_NULL, null=True) on the car, don't I set a One to One relationship from the Car to the User? I am going to watch your video One to One relatshionnship, it may help.
@codeenvironment3 жыл бұрын
Hello RC, please check the intro of this tutorial, it might help clear things up: kzbin.info/www/bejne/hHSlqayta9d3mtU
@johnrobertcool4 жыл бұрын
Can you please post edit and delete method?
@codeenvironment4 жыл бұрын
Do you mean a video for the [post, update, destroy] methods?
@@codeenvironment Hi I have one doubt can you help me to resolve that.stackoverflow.com/questions/64008694/multi-nested-with-django-restframework-and-mongodb
@sameeraperera79123 жыл бұрын
How we do one to many? I need to crate endpoint for ex- Order & order_details tables create using single endpoint Json- { "User_id" : "01", "Date" : "current date", "Address" : "address" Order_details: { [ "Item_code": "01", "Quantity" : 5 ], [ "Item_code" : "02", "Quantity" : 5 ] } }
@codeenvironment3 жыл бұрын
Use ManyToMany relationship for that
@sameeraperera79123 жыл бұрын
Thank you. But how can I create both pedant and child table using one endpoint.
@codeenvironment3 жыл бұрын
You have to override the Create / Post method in your view and send the nested or child data with your request . Check this tutorial: kzbin.info/www/bejne/hHSlqayta9d3mtU
@sameeraperera79123 жыл бұрын
Thank you again. I will try that.
@saisarath42943 жыл бұрын
I have created to nested serializer, but want to customize the nested output { Col 1: data Col 2 :data Nested data {col3 : data Col 4:data }} Required: {Col1:data Col2:data Col3:data Col4:data}
@codeenvironment3 жыл бұрын
Please email me your Django App code for me to be able to help you more
@geriarisman16213 жыл бұрын
Request For update broo
@codeenvironment3 жыл бұрын
Hello Geri, please explain your request more , thanks.
@6957-c5k Жыл бұрын
You started your explanation from a very top-level, displayed code even before explaining what you wanted to achieve. smh