No video

Django REST Framework Model Relationships

  Рет қаралды 67,678

Pretty Printed

Pretty Printed

Күн бұрын

Пікірлер: 97
@prettyprinted
@prettyprinted 4 жыл бұрын
Join my free course on building a Todo API with Django REST Framework: prettyprinted.com/djangotodoapi
@Iamkabera
@Iamkabera 4 жыл бұрын
Two years late, but this is one of the most useful resources I have come across.
@juandiegocastanogomez3854
@juandiegocastanogomez3854 4 жыл бұрын
Single Handedly the BEST video series on Django Rest Framework I've ever seen, and seen them all on KZbin, Udemy, etc. Concise, technical but just enough vanilla. Can't fully express my gratitude. This tutorial is so good that even though I have a student budget (haha) Iḿ really considering buying your courses. PERFECT!
@simplyajith1
@simplyajith1 4 жыл бұрын
True, this is the core and wasted some 40 hours in udemy.
@SatyamSingh-hz9su
@SatyamSingh-hz9su 3 жыл бұрын
Can you drop the playlist link
@swadhikarc7858
@swadhikarc7858 5 жыл бұрын
Awesome explanation. To those who get 'rest_framework.serializers' has no attribute 'HyperLinkedModelSerializer' error, this is due to the ModelSerializer itself handles the hyperlink url in the latest versions of rest_framework. Therefore, in the serializer class, you may inherit from ModelSerializer itself like class ParadigmSerializer(serializers.ModelSerializer):
@prettyprinted
@prettyprinted 5 жыл бұрын
Thanks!
@abhishekamin3090
@abhishekamin3090 4 жыл бұрын
ModelSerializer seems to bring the urls for its own model and will not work for fields such as ForeignKey which are mentioned in a different model.
@asiddiqi123
@asiddiqi123 4 жыл бұрын
Watched so many drf related videos, no one was as clear as you.
@bcaclassesnepal1992
@bcaclassesnepal1992 11 ай бұрын
Thank you for this please keep on posting great videos like these.
@BohdanDuCiel
@BohdanDuCiel 3 жыл бұрын
You might not know it! But you saved me a lot of research on my bachelor project, thanks a lot
@kiranpaithane3278
@kiranpaithane3278 4 жыл бұрын
Thanks a lot man... Lots of love from India
@geoafrikana
@geoafrikana 2 жыл бұрын
Thanks for this useful explanation.
6 жыл бұрын
Please make a course on your website about Django Rest Framework, including as much as you can... I'd buy it definitely.
@prettyprinted
@prettyprinted 6 жыл бұрын
That's part of the plan. Hopefully I get to it within the next few months.
@vinodsagar2412
@vinodsagar2412 5 жыл бұрын
Hi..... you are just awesome, one of the best explanation in youtube on REST FRAMEWORK.... thanks a lot
@prettyprinted
@prettyprinted 5 жыл бұрын
You're welcome! Thanks for watching!
@gaikwadabhishek
@gaikwadabhishek 6 жыл бұрын
Hi, I love your Django Series. I'm not able to understand how to use authentication and authorization with Rest framework. Can you please help me with that!
@jhoanmartinezsilva2609
@jhoanmartinezsilva2609 3 жыл бұрын
wowww, great work, amazing, huge thanks
@ZainAli-me4qk
@ZainAli-me4qk 4 жыл бұрын
Thanks man for great tutorial
@moshfiq
@moshfiq 5 жыл бұрын
It is so assuring to see someone else is having problem with typing serializers too. I feel you bro. 8:03
@prettyprinted
@prettyprinted 5 жыл бұрын
lol! I'm terrible at typing words I never use outside of programming.
@giovanniaravenam91
@giovanniaravenam91 4 жыл бұрын
Why the dropdown of the foreign keys of the 10:07 minute does not appear to me? I am using the following versions: Django = 3.0.4 djangorestframework = 3.11.0 djangorestframework-jwt = 1.11.0 psycopg2-binary = 2.8.3 (for Postgresql) gunicorn = 20.0.4 pyjwt = 1.7
2 жыл бұрын
hi, I had same problem while, you have to add field to your LanguageSerializer class fields = ('id', 'url', 'name', 'paradigm')
@akshaychauhan545
@akshaychauhan545 3 жыл бұрын
You're awesome man 🙌
@raghavarahulkalavala1542
@raghavarahulkalavala1542 3 жыл бұрын
Hi, I liked your video. I have a question for you. Based on the above example that you have shown, instead of many to many relationships, one to many relations works more good right? Because its also like one programmer can have multiple languages
@rahulvanmali1406
@rahulvanmali1406 6 жыл бұрын
Thanks brother! For django rest framework
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome! Thanks for watching.
6 жыл бұрын
Great man, keep continues excelent videos, thanks.
@prettyprinted
@prettyprinted 6 жыл бұрын
I won't stop! Thanks for watching.
@wechulipaul
@wechulipaul 4 жыл бұрын
Wow, this was so clear !
@prettyprinted
@prettyprinted 4 жыл бұрын
Thanks for watching!
@o___o4597
@o___o4597 4 жыл бұрын
Thanks a lot for your tutorial!
@alysonbrito694
@alysonbrito694 4 жыл бұрын
Great video! Could you please show me how to create resources using postman or any other type of client? The browsable api sometimes seems too "magic" for me.
@iancarr3923
@iancarr3923 5 жыл бұрын
Again very useful - thanks.
@prettyprinted
@prettyprinted 5 жыл бұрын
Thanks for watching!
@branquitodemunze
@branquitodemunze 6 жыл бұрын
How would you manage voters-polls, as many to many, but in a such way, that voter can do a certain poll only once? When a new poll is created, would you first immediately add all existing polls to him, and how would you set voted flag on a pivot table, so that he wouldn't be able to vote again on that particular poll. Thanks.
@leewilliam8606
@leewilliam8606 6 жыл бұрын
Hi,you really teach very well!Could you teach something about filter?
@moltenaluminium
@moltenaluminium 4 жыл бұрын
Using your example, Could you get a list of languages based on the paridigm? Something like GET /languages?paradigm=1
@vinay__baliyan
@vinay__baliyan 3 жыл бұрын
If I may ask, would it be possible to views programmers tagged to each language like we have languages displayed for each programmer?
@DeViLTh0rn
@DeViLTh0rn 4 жыл бұрын
I get Assertion error, after adding ForeignKey, "should either include a `serializer_class` attribute, or override the `get_serializer_class()` method." what should i do?
@miraccan00
@miraccan00 3 жыл бұрын
Thanks a lot it's helped me >.<
@vic_shine
@vic_shine 6 жыл бұрын
Hey, Anthony, good video here! :) thanks. Can you make me understand when I must to set _on_delete_ param to CASCADE or PROTECT or something else? What are they doing? What’s choosing? More usage example are welcome (and good idea for next episode, btw)
@prettyprinted
@prettyprinted 6 жыл бұрын
I'll make a video for that. But basically the idea to prevent invalid data. If you delete a part row, you must consider what happens to its children, and on_delete helps you with that. CASCADE simply deletes all the children. PROTECT stops you from deleting a parent when children exists.
@PhuongPhan
@PhuongPhan 6 жыл бұрын
Loving your videos you have a new subscriber!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching and for subscribers.
@serhii.chumachenko
@serhii.chumachenko 6 жыл бұрын
Nice job! Thanks!
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome! Thanks for watching.
@celiahassaine7788
@celiahassaine7788 4 жыл бұрын
I kinda followed u step by step but i get an error cause of the hyperlinkedmodel........." Could not resolve URL for hyperlinked relationship using view name", why do i have this error when i have followed the same steps as he did meh
@michaels973
@michaels973 4 жыл бұрын
is there a way to print the language name when viewing the programmer? Rather than the language id or url?
@vinayaksinghsendhaw8903
@vinayaksinghsendhaw8903 3 жыл бұрын
How do i change the colour of my api ..? Any idea !
@abirulezz
@abirulezz 6 жыл бұрын
Nice tuts! Can you please make videos on django AWS dynamodb?
@prettyprinted
@prettyprinted 6 жыл бұрын
I'll add that to my list. Thanks for the idea.
@kmasoftwares4303
@kmasoftwares4303 3 жыл бұрын
How t add status code and a message to the output json array
@TheShash1001
@TheShash1001 6 жыл бұрын
Can you make a video about overriding create and update for nested serializers?
@prettyprinted
@prettyprinted 6 жыл бұрын
I'll consider that. Thanks for the idea.
@PhucNguyen-bn9io
@PhucNguyen-bn9io 5 жыл бұрын
Thanks for your videos ^^
@prettyprinted
@prettyprinted 5 жыл бұрын
You're welcome!
@ALXG
@ALXG 4 жыл бұрын
Amazing!
@jrmartinss
@jrmartinss 3 жыл бұрын
And if I want to show the name of the language and its paradigm in programmers?
@farshadbadiee7133
@farshadbadiee7133 5 жыл бұрын
thanks for the great series of tutorial . but one question what will happen if we want to add a many to many between 2 models and some how make a third model for making the relation between them ??
@prettyprinted
@prettyprinted 5 жыл бұрын
I don't understand what you mean. Are you trying to use the third model as the model that will hold the data from both tables, or do you want a third table to related to one of the first two in some way?
@farshadbadiee7133
@farshadbadiee7133 5 жыл бұрын
@@prettyprinted actually yes third table to join the other 2 tables in laravel we call it pivot table and its responsible for many yo many relationships :)
@prettyprinted
@prettyprinted 5 жыл бұрын
@@farshadbadiee7133 What Laravel calls a pivot table Django does automatically. Since pivot tables are very simple, there's need to specify them directly in Django.
@farshadbadiee7133
@farshadbadiee7133 5 жыл бұрын
@@prettyprinted Thanks For great answer do you have any plan to make any toturial about many to many realtionships ?
@prettyprinted
@prettyprinted 5 жыл бұрын
@@farshadbadiee7133 I will eventually.
@gauravswarankar2557
@gauravswarankar2557 3 жыл бұрын
can i get the link of this project api. m not geting on your github or any below link.
@jayceazua723
@jayceazua723 5 жыл бұрын
I'm having an issue: instead of using sqlite3 I am using postgres, however whenever I try to use the MyModel.objects.all() it simply states that my model does not have a property or method named objects.
@prettyprinted
@prettyprinted 5 жыл бұрын
What is the exact error text?
@yahyakharrazi4176
@yahyakharrazi4176 6 жыл бұрын
Thanks for the very helpful videos! I'm working on a page it has a form and inside it has many comboboxes containing data from each tables, I created for each table in my database a serializer class and a view to retrieve data from each tables, the problem is while I load this form page it takes a while to load. So i'm guessing if there's a way to join unrelated models
@askhatarslanov6327
@askhatarslanov6327 6 жыл бұрын
Maybe select_related or prefetch_related can help you.
@kristoffergonzaga5531
@kristoffergonzaga5531 5 жыл бұрын
Hi, I would just like to ask why my languages field in kzbin.info/www/bejne/h3OcmHp7rN2rg5Y is not showing and just the Name field? Awesome video by the way!!
@kristoffergonzaga5531
@kristoffergonzaga5531 5 жыл бұрын
But it works when I add the data via the admin
@pilotandy_com
@pilotandy_com 5 жыл бұрын
Thank you! Your tutorials are great. Is there a way to change the hyperlink for the user to still take you to the user, but SHOW the username? Or show the language names known by each user? make it more human readable? i.e Bob/
@MusabbirMamun
@MusabbirMamun 4 жыл бұрын
Good question. Can you please give the answer of your own question?
@vinceramcesoliveros6739
@vinceramcesoliveros6739 4 жыл бұрын
shouldn't be the languages not urls , but instead the object properties of the languages. so in a front-end app. we're going to fetch those urls 3x instead of 1? I think its better to have something like this { "languages":[ {"id":1, "name":"Java", "paradigm":{"id":1,"name":"OOP"} } ] }
@vinceramcesoliveros6739
@vinceramcesoliveros6739 4 жыл бұрын
got it. just add `dept=1` in the class Meta of the serialize model
@vinceramcesoliveros6739
@vinceramcesoliveros6739 4 жыл бұрын
but I lost the capability to post languages if add the depth
@testtest-xg4bf
@testtest-xg4bf 2 жыл бұрын
от души братан
@kyojindev3978
@kyojindev3978 6 жыл бұрын
if there will be 2 k languages, how to make pagination on it?
@prettyprinted
@prettyprinted 6 жыл бұрын
I'll probably make a video to cover this, but check this out: www.django-rest-framework.org/api-guide/pagination/
@kyojindev3978
@kyojindev3978 6 жыл бұрын
pagination inside json item? { 'album_name': 'The Grey Album', 'artist': 'Danger Mouse' 'tracks': [ {'title': 'Public Service Announcement'}, {'title': 'What More Can I Say'}, {'title': 'Encore'}, ............ 1k ], }
@ikhsanrahman9703
@ikhsanrahman9703 5 жыл бұрын
nice, would you like to share some complex example ?. thanks in advance
@prettyprinted
@prettyprinted 5 жыл бұрын
I definitely will make more complicated examples in the future.
@maxennybee
@maxennybee 5 жыл бұрын
hi love your videos. i have a question. how would you handle a self referencing model with a many to many relationship?
@prettyprinted
@prettyprinted 5 жыл бұрын
You use quotes. Like this: stackoverflow.com/questions/15285626/django-self-referential-foreign-key
@maxennybee
@maxennybee 5 жыл бұрын
@@prettyprinted Thanks once again. While this is very helpful for me and is what i might actually redirect to, however, i was looking as something like this that has many relationships e.g custommodel = models.ManyToManyField('self', through='JoiningTable', symetrical=False). Django doesnt populate the joining table or how do i get to do that with the api.
@maxennybee
@maxennybee 5 жыл бұрын
@@prettyprinted Also while trying that option, will i allow null=True ? especially for records that dont have a parent_id
@prettyprinted
@prettyprinted 5 жыл бұрын
@@maxennybee Yeah, if you don't expect each record to have parent, then you want null to be True.
@george4746
@george4746 6 жыл бұрын
is there any way to add a non-model field in the serializer.
@prettyprinted
@prettyprinted 6 жыл бұрын
You should be able to, but I haven't tried it yet. You may have to override the to_representation method. www.django-rest-framework.org/api-guide/serializers/#to_representationself-obj
@ivonherms
@ivonherms 4 жыл бұрын
I can't read the code
@tejasgajare542
@tejasgajare542 6 жыл бұрын
Can you please help me with Authentication and Authorization with Django Rest Framework?
@prettyprinted
@prettyprinted 6 жыл бұрын
Videos on that are coming soon.
@BookOfSaints
@BookOfSaints 5 жыл бұрын
This was a good video, but it lacked practical use, such as making actual api calls on an application, even if a simple one, to demonstrate these concepts better.
@prettyprinted
@prettyprinted 5 жыл бұрын
I'll consider making more realistic examples for this.
@skyblaze6687
@skyblaze6687 2 жыл бұрын
dude it totally stupid part of video better u should remove two model table api cant work their (imagine if u create 3 and have instances different id ) probably when u click on api pk value it open on different id just assume id save differently foreignkey doesnt help u to give different id for exact model table
How to Use Django REST Framework Permissions
11:06
Pretty Printed
Рет қаралды 40 М.
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 14 МЛН
Touching Act of Kindness Brings Hope to the Homeless #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 17 МЛН
JSON Web Tokens With Django REST Framework
16:58
Pretty Printed
Рет қаралды 91 М.
Getting Started With Django REST Framework
26:31
Pretty Printed
Рет қаралды 199 М.
Understanding Django Model Relationships
25:56
Pretty Printed
Рет қаралды 94 М.
Django Rest Framework | Serializers & CRUD
22:40
Dennis Ivy
Рет қаралды 385 М.
Django Rest Framework for Beginners - Simple CRUD API
14:22
John Watson Rooney
Рет қаралды 49 М.
Django Rest Framework API #22 / Many To Many Relationship , Nested Data
31:20
Django REST Framework Oversimplified
9:43
Dennis Ivy
Рет қаралды 322 М.
Django REST Framework - Build an API from Scratch
40:39
Caleb Curry
Рет қаралды 215 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 169 М.
Django DRF Project | Implimenting DRF Viewsets | 16
7:17
Very Academy
Рет қаралды 8 М.