APIS with Django REST Framework

Video in TIB AV-Portal: APIS with Django REST Framework

Formal Metadata

APIS with Django REST Framework
So easy, you can learn it in 25 minutes
Alternative Title
Django REST API - So easy you can learn it in 25 minutes
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 4.0 International:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Django REST Framework can make creating a RESTFUL api quick and easy. Join me as I go over: - What makes an API Restful - How Serializers can make representing your existing models in JSON a breeze - What the built in Views provide for you, and how to provide authentication for your API - How to route to your new Endpoints - Last but not least, how to Unit Test them
Computer animation Mathematical analysis Energy level Software framework
Server (computing) Arm Physical law Representational state transfer Client (computing) Power (physics) Category of being Type theory Computer animation Internetworking Hypermedia Different (Kate Ryan album) Operator (mathematics) Quicksort Software architecture Physical system Form (programming)
Point (geometry) Authentication Dependent and independent variables Arm Token ring Multiplication sign Mehrplatzsystem Archaeological field survey Mereology Code Number Computer animation Quicksort Error message
Word Server (computing) Computer animation Term (mathematics) Multiplication sign Model theory Video game Software framework Cartesian coordinate system Resultant Form (programming)
Point (geometry) Default (computer science) Dependent and independent variables Randomization Context awareness Serial port Validity (statistics) Code Length Multiplication sign Source code Model theory Electronic mailing list Combinational logic Maxima and minima Multilateration Mereology Field (computer science) Attribute grammar Logic Configuration space Error message Resultant Capability Maturity Model
Point (geometry) Information State of matter Gender View (database) Staff (military) Disk read-and-write head Theory Twitter Computer animation Authorization Software framework Object (grammar) Procedural programming
Point (geometry) Serial port Model theory Electronic mailing list Archaeological field survey Database Variable (mathematics) Demoscene Twitter Query language Operator (mathematics) Object (grammar) Social class
Point (geometry) Inheritance (object-oriented programming) View (database) Operator (mathematics) Electronic mailing list Combinational logic Bit Software framework Object (grammar) Endliche Modelltheorie
Dependent and independent variables Serial port Code Multiplication sign Weight Client (computing) Demoscene Power (physics) Computer animation Query language Hypermedia Representation (politics) Software framework Pattern language Data type God Form (programming)
Point (geometry) Default (computer science) Pairwise comparison Multiplication Set (mathematics) Bit Twitter Category of being Computer animation Operator (mathematics) Configuration space Pattern language Quicksort Router (computing)
Web page Dependent and independent variables Computer animation Demo (music) Gender Multiplication sign Interactive television Software framework Bit
Server (computing)
Existential quantification Serial port Arm Demo (music) Code Multiplication sign Unit testing Representational state transfer Field (computer science) Computer animation output Cuboid Software framework
Authentication Word Group action Message passing Computer animation Information Validity (statistics) Chemical equation Software testing Unit testing Exception handling Twitter
Point (geometry) Complex (psychology) Electric generator Computer animation Validity (statistics) Personal digital assistant Code Multiplication sign Model theory Software framework Endliche Modelltheorie Product (business)
Serial port Computer animation Horizon Software framework Discounts and allowances
Complex (psychology) Serial port Arm Key (cryptography) Code Multiplication sign View (database) Model theory Source code Sound effect Insertion loss Online help Student's t-test Web browser Flow separation Programmer (hardware) Data model Lecture/Conference Calculation Pattern language Office suite Endliche Modelltheorie Quicksort Error message
and this and that and so on and all the data on this morning so what this talk is anonymous level talk and that this is analysis to get familiar with the terminology of the API eyes and the competence to exploding arrest framework on on their own of out
that is rest what is best for arms because it gets talked about a law I will it's just an architecture and the use of the media has a has a few properties that define a RESTful API I a path to the several yeah the client doesn't have to maintain the the sort of knowledge about the server each request is kind of mean as if it were fetched I suppose comment HTTP methods of such is the actual system looks fine and it to the Internet and the types like J. font or axonal from so it
in emerged as these are the are the problem we have to get put patch and do we active flight crews and so on not only power so we don't have the form operations on different and up unquenchable
look kind of like that so that 1st time point if we can't generate it will return a collection of all users the 2nd point we have a constant 90 and it will return if we call get on a log return a single user arm at ID so I through the other end about the GDP verbs and how they look like if we call the money and if we call this part post on our 1st employee it would create a new user if we called under LEED on and when it was just an Aidid it would delete that single user if a company on our users collection it will tho we of uses them number the a
and here are some common HTTP response codes that response codes that you'll probably see when you're using your API on so too it is OK to I 1 if you call post unemployment benefit wanted to return that means that resource was created but 1 is not authorized so bend my requires some sort of authentication like token and you do not provide it up for what common 1 I the survey did not find a resource they requested and our 500 is server error it so
what I'm going to see if the hard to pronounce words I wouldn't needed by the application and produces the same result when and how many times it is repeated so important to leave and imposing won't get his estate market it might not return the same result at the time but by calling it you're not modifying any resource and the you know that the server isn't enough to doing anything funky term I miss about object that you're trying to get the
so here is where comes and given half is generous framework and the impact aggregation really really means z so cylinders the can can be thought of as jingle forms they're dying to representing the data over the life years time giraffe hand on that digital work so here we have a model
between it's very simple I We have a foreign key users we have some context the the maximum length is 140 characters and we have a times so to represent that data but would want to make a serialization let us among so when it has serializer that the user that comes from the source all users and and that is where we define which model were trying to serialize and what fields I'm not what we're trying to represent the also alliances are also available in kind however bunch of random data In Warner creating and point out of it you can create a serializer but have matinees fields FIL that will be available to you if you actually have to define every serializer 1 by 1 so when we pass a data the serializer this is what the result will look like that if out we support if I if we consider due to some back on responses which are the default I kills the path that x now and not just as simple as that in your i have to change any of the code it would so you can have that supports really great validation and I choose not
as field validator looks like so an interesting thing to note is that it can have but that I played in a method called validate underscore attacks the it have we knows that this holiday there is point that text review there's no configuration here just kind of naming convention so sharing tagging I'm sorry I have to be part of the list of items and we're checking CFO length in other is lost find out if it you know if it is within the all additional that that's the Texas you short what they get back and error response in the EPI the and I can live validator is unavailable is is valid I If you have about method your serializer you can actually validate our combination and attributes for example if you have a start date and end date you won't our anyone mature later and date it is at the frontier start date you about that ideational logic in your is valid Our method the and if you want to make sure that your serializes now and you can call that method on pretty similar to a jingle for the so permissions
How what say we only wanna let authenticated users theorist of tweets so it is not indicated is actually about information in gender arrest framework and doesn't it said that we loved with indicated users to hit that employ them Bolton 1 is is admin user and a chance to see if the user is actually on staff member or not if are creating your own body atmospheric emissions are actually very amusing but the oven then we want the author of the tweet to be able to edit so we create our own permission I would off base permission and we trade method compound object permission so we before i point is head that object is passed into this procedure and we check if on method is in state methods such as gap go ahead and look and see if I if they're trying to call something destructive like delete make sure that the object user is the same as the request users user the so views
of the to really interesting topic India however the easiest 1
to kind of get a grip on is called a new set the here is an example of a model of user so I will have to define a few simple variables to be able you the Jesus and point out we have a query so that's how do we get a collection of items that returned to you we define our serialization we define a list of permission classes on which you can provide a set as long as you like for each of your points but we can also define an Hindi precinct method so that it's called the forward object is saved to the database and we want to our and the user of a tweet to be saved as the request user so none you that is kind of low-cost surveying and 1 behind the scenes it supports all the operations on an 10 point so you can get 1 tweet by 90 you can get the collection of tweets however you can see the way you can modify and kind of all given to you balancing of costs it's really in the
so it could be said to us and we're working with models but sometimes you have to break things down a little bit more so how do you estimate the by generic views Our again use the base class current takes care of all the running so if you can't get it all called get method I emittance provide common operations so and some do not use better provided for us that we have a common combination of Nixon's for example are the if you're only supporting the point that has a list of objects that you would call that a concerned with you the list create a kid you and it would not support GET and POST for you and you can have 2 foreigners to tell us the
requests and generous framework
and still pretty similar to the then the methods that were used to seeing it so if you guessed and use jingo forms you're used to seeing a request stop post announced the data that comes in when the user submits uniform look at the idea is that kind of similar it provides on FIL that was submitted to the API along with the values I think you know all the data types we specified God I produce much exclusively use J somebody some of you might like x amount the
and responses also could some but not really so general that less than 1 responses are actually completely on unwarranted you're getting a bunch of data back and it's up to you to short hand on a consumer so you only via using query on the client to call this power and weight how media using angular or another JavaScript framework but what's going on behind the scenes when you call the winning response stock if you're using a serializer is your query set this tweets from being passed to the serializer the serializer does doesn't work patterns that so but she's our representation and then you call response with that serializer data are they calling response with no status code you actually just standing back a 200 check if I he wanted to process request your serializer you in past requesting into your serializer and then called summarizes doctor is valid before actually performing the same time otherwise terrible things happen so
let's talk a little bit about reality use that
writing is absolutely the simplest so we have I with Clinton default and we register our sets with their the nice thing about using 24 hour in is we can pass all sorts of configurations to act for example on if you don't care about a pending trailing slashes that's the property that the comparison to default router on our instantiation so many registered only to do is included the rather neurons in your neural patterns what did you is the whole should pay you have because tweets multiple and point you have a single to be unemployed and the support of the operations on those and once as well the jet the palace Chile perhaps kind of this just fast the so without really sets In these setting after around I am a default way so creating overview and then register each year all pattern about going here i is
our main 1 of the strongest features of the
the genderist framework so it did you our it can point right you can kind of she and served letting just under no edges on response you'll get I note that this kind of interactive pages and you can see it all the time methods that are available on your and body by about gender and you can have they can provide data to I think we actually have time for a little bit of a demo
so seen future my servers
running it it
but the strips
Rasmussen with my code so now so about by guidance kind of the kind
and what happens when you do alive demos so when you're talking right something's always broken and so using the example of the data that you can path good your each chapter made sure that the data passing and his allergies sign arm and then it matches the fields in your serializer all general rest framework provides this he indeed indeed it should not form time so it provides the correct input box for the data trying a person unit testing everyone
loves the testing go it the it's
important so in the past he finds the defined as steel validator the that can make sure that all the the tweet that someone is trying to submit it is more than 5 characters words in balance so choose the creating of at test for that validated who is not here 1 by 1 and see what's going on so we define an API which again has many useful methods our 1st of for us for unit testing and you were about well logging in well authenticating have the request so if we didn't have that in and we have an authentication information then we would get our for back not authorized How are we getting the Ural for the and when are making up some tested on Social print out for actions and I will post into that you're out to create a new tweet and be a similar message so we want assert the saddest Curtis 400 that means a battle West your data and knowledge we wanna ensure about the other message is the same 1 that I we provided in the validation exception Ch
7 How do we know pretty extensive way for the past few months and that we have using the dark so the best place to user is new products and you know I have to cold for that framework were around framework you can use some of their new powerful tools that are available I such as those used that's why you have clean models I know timing interdependent validation going on how in that case it's it's really just ask for it it saves you so much time so we
want to use that understanding those out there if you have a time of complex model of interdependent validations to travesties non-modal yields in your and points things really can get tricky I you don't get to use but if use that you can have to break out and use this generative use that's and customize your code to deal with some these complexities so the Venetian go
for it right there might be hurdles the and that's the only by then i and j know framework 3 is on the horizon and apparently are going to be fixing some of the issues but I've had and your moon during the serializes completely so don't discount can keep an eye out for it just looking out for some issues so much sense for you
there's pippins bounding arrest framework the documentation in really good and they tutorial is very thorough so hopefully it had familiarize you with some of the terminology that you'll be seeing means and that for me you
invent it theft they so much you know I think we do actually have time for perhaps 1 or maybe 2 unbelievably rich western so that he has a net loss I Spatial and present could you also the is there any sort of vesicular pattern we think that is what was models with a view I suggest like so this is sort of a customer's lationships source foreign keys like what we reviewed by C programmers on how to handle that and to the more complex constructive I will be able to do our our you know before you can't use indefinitely start hopes to have those built and things like this using your calculator much code to be like when this request as get to rest on and the BDI browsers Pintrich account for helpful tool that it's it's still worthwhile kind of exploring even for more complex data models but you can the you as as moving you wouldn't like clean models in that sense it didn't really it was the office or old code of those worries we thought that in some ways but something that I looked at I I to this issue of older there's already thought it was it to be it was prior to the great out serialized as far as practical or it's actually kind of pretty tangled up together here effect which relates and because most of us at least some colonists the whole thing I actually tackle that problem with a very complex model both ways but that's analyzer and without a separate serializer on he's analyzer half and the scope of this talk but I'm happy to talk to you about afterwards arm and really did provide for next things for example and field-validation like I westernizer only accepts 140 characters instead of the model of backpack correct error whereas if I didn't use the serializer it have to do all that kind of bombing myself argued a kid thank student and this and this is the the the thing and