Hackathon: Build a complete Django REST API with me! | Python & Django

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to another live stream on Faraday Academy and today we're gonna be starting and hopefully finishing the MVP for a new API in django REST API so if you're here then go ahead and say hi in the chat hi Jared hi cigar hi Phil yym from Boston Boston is my favorite city by the way I actually grew up there um hi hi Bella bees I think hi everyone how are you all also very important today is my birthday and I'm getting a cake delivery later so this might be you know like a three or four hour livestream and I will be taking a break in the middle to go and eat cupcakes which is very important so if you want to send me virtual cupcakes then feel free to do that too thank you awesome and I couldn't think of a better way to spend my birthday than coding all day alright so this is the repo and if I did if I set this up right thanks everyone advice yay cupcake if I set this repo up correctly then or as I said the stream up correctly there should be a link in the description to this repo here so you should see free code school indie student management system it's a public repo and yeah it's just information I did write out the requirements what we're going to be doing in this video as well as the schema and not all of the API endpoints but the ones that are going to be used in the app end application so we're not building the front end today but the front end we'll be using these yeah and then version two so basically I'm gonna get started doing the user first so that I can go ahead and set up the database and all that stuff because if you know Django save you a piece if you come to Indianapolis I'll share as much as much as you want so Django uses username by default so we have to change that right away so we use email for the default user login and then we'll go down and set up all these other models we're also going to be setting up token authentication and protecting endpoints and then if we have time after or maybe in another special stream we'll set up okay so Jared is actually the one building the front-end for this application so he'll be streaming on Twitch later so I guess I'll post that link later if you want to see him building a pjs application for the front-end cool yes I'll set up token authentication and then if I have time I will set up or at least start to set up github authentication I don't think I said what this app was for sorry this is basically for keeping track of the students and student information and giving us some admin features for our free coding school and then this will be open source so anyone else who wants to start a free coding school can also use this code and this repo for free yeah we should all just get cake and have a virtual mukbang cake session for my birthday that would be awesome all right yeah so this is for student management for these free coding school groups that we set up on here and other people are also hopefully setting them up right now or working to set them up around the world okay yeah so that's basically the overview if you have any questions you can let me know I did already create the app in github to set up github just in case I started it today so I could save the keys locally so no one sees my secret keys in the stream so we'll see how far we get there all right so I created this folder so I can do Django so I'm going to create a new Django project here so I think it's Django admin and then start project yeah that's the same thing I did last time okay good what should I call this project I guess I'll call it free code school API sounds good and now I have the API folder so I'm going to CD into that folder and then I'm gonna open this up in my BS code all right now let me rearrange my windows really quickly put my browser in the middle that's how I like it all right and now I'm going to okay so now I have my managed by file and I have this basic I guess API it doesn't so this is just regular Django it doesn't have Rick Django rest framework installed yet so I'm gonna have to set this up and I also have a few housekeeping so on this repo if you go to projects the projects tab on the repo I have a few issues that I created so I can kind of step through and check off tasks or drag them over to the done column thanks everyone okay so the first thing create Django project which I just did then I'm gonna change around the config and naming so it's a little bit nicer I need to generate a get ignore file for my project and then I'm going to add linting setup so why don't I go ahead and do the get ignore get out of the way so I'm not pushing my cache files again like I usually forget to do the first time so let me go to get ignore dot IO and this only takes a second so basically I guess topped a lot them I think they were advertising that they wanted to be bought and then top towel went and bought them which was a smart move okay so I'm going to say Django and Python and then I don't think they have vyas code maybe vim yeah just in case okay I'm going to create this get ignore file cool and then I'm gonna copy this generated file and then I'll create a getting more here get ignore all right so I'll paste all that in I'll save it yeah see that okay one housekeeping item out of the way let me drag that to done and then setup linting okay so I already basically I need to create a vs code folder in here and then I'm gonna use flake eight for linting I used to use pilant but flake a is just so sweet and so nice so all I need to do is let's see I have notes here because I always forget the linting one second so okay so I need a vs code folder and then a Settings JSON file inside so I'm going to create that here no new folder dot V oops I'm going to say dot vs code okay and now inside this I'm gonna say settings dot JSON and then I'm just gonna paste my settings basically I'm setting my editor tab size to four because I'm using Python so I want four spaces on a hit tab and yeah sending it to fly gate that's basically it okay so save that now that's all done and now okay so my setup is done and now I am going to change the main app folder and add a new folder so if you know Django you know it's built of your main project which is what I created here and then it's built with all these apps but it gives you this default app out-of-the-box with the same name as your project and you have your settings file and your main URLs and all that stuff in here but it's confusing because the folder the outer folders named free code school API and then it gives this inner folder the same name so I'm gonna actually change this folder name to config I think that makes it a little bit more clear but then am now in my manage PI file I need to find all instances of free code school API there's only one okay and then oops undo undo what did I do no exit yeah one more time let me try that again find and replace and then change it to config because that's talking about the folder name that's a package in Python okay so I ain't changing that to config to access the correct folder and then in here let me search through the rest actually and because I think there's a few places free code school API I think there's a few spaces in the rest of the application some of these are just comments but which I don't want to change and some of them are actual places where I do want to change it to config because it's trying to that's the file so it's going to be config dot URLs this will be oops config dot URLs okay that's just a comment this is now just a comment this is can oops a new undo config dot settings okay I think there's one more yeah WSGI which not gonna be using I think but just so it's setup correctly okay now all of that is done my folder name change is good so let me go back here and now let me add a folder to put all my apps in for Django so I'm gonna create a new folder called apps and all of the apps I create are going to be inside of this folder so I'm gonna create a user's app so I can go ahead and set up the users API wait did I do all this yep I did all of this setup okay so set up the user model so let me create that user app first Oh before I do anything first let me create a virtual environment almost forgot to do that so before I go installing random things in my global space so python - m and now i'm going to set up a virtual environment and i'm gonna call it VN enter let's see okay and now if I go over yeah now I have my VN directory here good let me just make sure that the n my virtual environments in my get ignore let me search for that yes no yes it is okay good so my VN folder good good good so I'm not committing that and to get all right so now let me get into my the end source VN bin activate and now I can do whatever I want because I'm inside my virtual environment so the first thing just to set up the front-end repo oh good good I actually didn't watch your stream but if you don't know Jared Jared and I are both organizers for this free coding school project where we provide curriculum and learning environment and classes and everything that students need to learn for free over a three-month period and learn how to code it's been a lot of fun together but we need more management tools which is why we're building this app okay to be more organized so free code school API so let me install let me do a pip install no Django rest framework let me let me copy paste that so I have it right Django rest framework setup here pip installed Django rest framework okay it's installing and then I'll pip freeze that to save that dependency my requirements that txt file okay pip version why am i using that pip version I think Python yeah I'm using Python 3.6 that doesn't really matter I could be using Python 3.8 I have pi end so I keep switching back and forth and the company I worked for is uses Python 3.6 so that's I have it currently but that will make a big difference right now okay so I'm gonna go ahead and upgrade pip though cool so pip is upgraded now I will do pip freeze save that dependency okay and now I can create my app so I'm going to tell Django to create the user's app so I can start building the users API Python manage pi start app yeah Oh a Louie because it's inside my apps folder and not in the root directory I need to first create that folder so I'm gonna make directory inside of apps I'm gonna say users because otherwise Django is gonna throw an error and say the folder doesn't exist for some reason okay and now I can Python managed dot pi start app yeah start app i keep getting confused between create up and start up and start up and then apps slash users oh wait i have to it's called users and i'm putting it inside of app slash users okay so the name of the app and then the location okay seem to have worked let's see if the new app is there inside apps okay apps are does indeed have all this stuff good it's just showing both of these because there's no other folders inside apps but i will create so since this is a package structure i need to create in an it dot pi file just an empty in it pi file okay and now I have my users folder inside of apps and that should have yeah that automatically has an init dot PI file great all right so I have that now in my config I need to tell my settings let's see I need to first tell it that I'm using Django rest framework nope Django rest framework and then I need to tell it about my let's say apps dot users about my apps that users file or yeah my apps tight users app okay because it's in the apps folder all right so I have that set up flake eight is not installed oh I guess it inside this virtual environment it's not let me install it alright cool flaky is now installed so if you use flake eight down here it will show you the problems that you can fix and I like going through them manually and fixing each one oops what am i doing no exit okay so yeah so how's everything going is everything clear in the stream so far I'm gonna go ahead and be setting up the user models and the views for the user and I think this is well this is definitely the most finicky part of setting up Django and why you you're also supposed to do it first so let me let me see civilization I don't want any of that so let me go to great so Django rest framework user setup and it's easiest they have a pretty good tutorial is it quick start where they take you through setting up users but for some reason and their documentation I always have a hard time finding exactly what I want let's see it's not under oh I guess okay so I do need to set up a serializer to get the data how I want and then set up a view and then set up user URLs so what I might do is just use my previous project as a reference I'll bring that up here so I have github calm I'll just find it from going to github so let me go to here this is the repo so I'll post a link in the chat - if you can see that cool alright so in this is an app that I set up recently it's also a jingle risk framework application so of course I set it up the same way because this is just how I prefer to set up my apps my Django apps so I have all of these and so it's real finicky how to set up the user model in Django so let's see let me start with the Django router cuz Django rest framework it's not I mean you still have your let me zoom in so you can see this okay so you still have your user this is in by the way in users URL spy file so you still have your regular URL patterns list like you do in regular Jenko but it gives you this special router this Django rest framework router so I'm actually going to copy this because I want pretty much the same thing for my users here so oh wait I'm in models right now let me go to oh I forgot Django doesn't create a URL spy file for you so you just have to create that file alright so I created a user urls up pie inside of my users app ok so now I have this and I'm registering the users route here but you can see the path is empty and this is because I need to reference this as slash users in my config URLs so right now I only have the admin interface set up because Django just gives me that by default so let me do path which should I say users and the accessibility for this might change I just want to be able to pull all users the app name should be rest framework thank you um thank you I think I set that up wrong let me do that in just one second so here I'm gonna have to import what was it I had to import man I have to look up so many things no no not an apps actually my config so in my config here in my URLs yeah I need to import include and then include the path to the URLs so include include yeah and then the past so it will be apps dot what's the folder name users dot URLs so include those URLs under users slash and actually the prefix that I want for this as well isn't just user slash oh now everything is oom did I guess that's ok isn't just user slash if I look at my API here I want there to be API v1 it's like a properly make this API so I'm gonna just prefix and I've always done this manually I don't think there's a way to do this globally also my admin route I mean I don't want to oh I can nest routes but anyway let me just do API v1 users and then admin I don't want to put in the same thing because they're gonna log into the admin interface separately okay so include so I need to import include here so include okay cool oh yeah and then you brought up it should be rest framework you're right this this needs to be rest framework Thanks okay so that should be properly done now also I think there are a few other things too for the rest framework this is the github ah stuff so let me look up jingo rest framework QuickStart make sure that I set it up correctly alright so it took me through creating the app I'm not going to do migrations yet okay setting up serializers views yeah I'm doing all that stuff installed apps okay so I think it's just installed apps and then I get to set up my views and URLs and everything normally okay correct me if I'm wrong alright so now I have my users URLs being imported please look in the settings file please look at what in the settings file let me know what I should be looking at I know I have a bunch of flaky errors but I'm gonna fix that in a second all right so let's see oh yeah I'm gonna be using Postgres as well let me add that to my task my dev tasks list set up Postgres and that's actually pretty easy to set up so I think before my first migration because on my first migration it's going to create a sequel light database because I have or is it where is it I have this set up so I might just go ahead and copy my post grass so I can you know properly use it without having to configure it later okay so let me do that as part of my setup then if I go to my other repo I'm just gonna copy my Postgres setup from here so my settings I'm gonna go to let's see oh yeah I'm gonna need this this plugin as well but I'll do that later where is my Postgres here it is so Postgres I'm gonna have to create the Postgres user so I'll go into the P sequel in the terminal and do that let's see anything else I need oh yeah I'll have to set up the media and stuff so man there's a lot of configuration docker eyes app dev and of this yes so actually I do have so my curriculum app I've been IDE authorized that I've been planning on making a video about how I'm docker izing and deploying it because I really use docker compose and docker eyes the front-end and back-end separately and they're running separately and talking to each other so I do want to do a video about docker icing and maybe I'll do it live let's see okay so first first first first get rid of that and now I need to create this user hopefully I remember how to do that in peace equal Postgres so the name of my database is not going to be that it's going to be let's see free what did I call it before okay so free code school that sounds good okay cuz it's only gonna be one database running anyway but I have a bunch locally so that'll be good so user off to create this user which will be FCS admin okay for right now host is localhost that's completely fine and then since I'm working on settings when I upload files or images I need a place to put those so I'm gonna just copy these to my media root and the URL to access that media so I'm gonna post paste those there okay yeah this is a lot of config alright let's go back to users now as I think I'm good yeah if you see I'm missing something then let me know okay I'll have to do that and I have to I need to create this table actually let me just go ahead and do that because I'm gonna forget so let me go open another terminal window and I'm gonna go into and what is it PS I already have Postgres running locally on my machine so don't need to run it because I'm running it with homebrew because I'm on a Mac so psql I'm just gonna hit up and hope some command comes up um Postgres use your Gwen okay that looks good okay so now I'm inside the Postgres Jill hmm and now what am i doing oh yeah create create database free code school sweet that worked okay create database free code school and then can I do use database use free code school um I don't know let me let me see create so it created the database I'm gonna have to look this up so Postgres drink water thank you I should sorry if I was making noise into the mic I forget I'm doing that sometimes so Postgres create I guess admin user for database creating user database and adding access on Postgres I hope this is it in the terminal yeah okay so create database okay so I need to do create user my user oh this isn't the actual command I was like that's a lawful long very human-like command okay so create DB sudo you Postgres granting privileges okay here's what I want to do with P sequel in the terminal create user all right so I'm gonna know I'm gonna type this out thank you great user so create user your user let me zoom in so I should do create user your user it's recommended all caps but it works with lowercase - so my user is the one I set up in Django is FCS admin and then with encrypted password I'm just not gonna put a password right now so there we go okay so I created that user and now I'm going to let me copy the first part of this my trackpad is broken so I have another mouse here it's not broken for somebody that stuck in clicked mode so I don't know if I have to take this computer apart or what but it's like five years old so maybe it's time for a new computer okay so grant all privileges on database free cook free code school - and then the username so my username you just put it off her case is FCS admin FCS admin okay sweet and that's it that's it what a great tutorial I wish I could clap but I'm not logged in just short sweet and to the point alright so what am i doing now okay let me exit this and go back here okay so I've taken care of the database I did a lot of the setup I'm gonna get out of my settings file now get out of there and now I am in my users again so in my users I'm gonna need to I guess create my views first so my views I'm gonna need the serializer and I'm going to need the regular users view so let me see what should i do first I'm actually going to start off with what I'm using in my other project again so let me go into apps here into my users app and in my views actually let me start with models I think that makes more sense so I yeah this is there's so much boilerplate so I'm gonna start just doing one thing at a time so custom user manager basically because I don't want to use user name for login I need to create a custom user manager first of course that extends from the base user manager or the class extends from that class so let me copy the top part here and how to thought how do we handle group projects so when the students are working on teams I have no idea no idea hadn't even thought of that so how would we handle group projects so we do so in the in this API or in our schema we have let's see we have projects that the students are supposed to do but these are just a list of what the project is and then the Prada student can submit their project and this is you know has a student ID the project ID and the URL to the project that the student submitted there is a there is no way to set up I guess assign a project to a student and there's no way to say mm-hmm more water wait one second and there's no way to and there's no way to say that this group of students is working on a project together on the on the user page you would see your projects with a link to the pen repo glitch a grade but how did they see who else worked on it I had I don't know give me some suggestions how do we extend the scheme of the database to join them using primary foreign keys so this will I mean these are foreign keys so we're gonna set these up with foreign keys some of these tables will be generated I think we have some many too many or one-to-many relationships what did I do here oh I was trying to figure out how I was gonna handle this table so put some extra info maybe project ID will be the same for students working in the group so project ID yeah there should be some kind of ID the thing about project is this is just a general project like say we're doing a Google look-alike page all the students need to build it the title will be Google look-alike page the description will be whatever and then the URL to the project requirements or whatever so all students will be assigned this so if a specific group of students I mean so all students will have the same project ID here when they submit so for a group I don't know we might have to have another project group table here so that the students can be in the same group somehow and the project group table will be related to project and then in the student submission so project group can be know a project ID can be nullable and instead they can or no we can have an optional field called project group ID thank you for having a project instead of being a string of the URL could be an object with the URL and the users that worked on a project hmm an object though in a I really don't like doing that in a relational database I mean it's it would be okay if I was using like dynamo or or something that would be easy but I think I mean what if we did have a student a student group submissions table and then where am i where am i a student submission this should be like student project submission or something I don't know so we have project maybe we should have project groups and then we have the groups I don't know we'll have to think think about this because we're not even out even close to that part of the project yet also we need a way for them to highlight the project okay oh yeah highlighted project okay okay we're getting so far ahead of where we are right now but yeah those are all good ideas why don't you create an issue with those ideas if you can that way them for later and they don't get lost okay um setup user setup Postgres okay Postgres I'm gonna drag that over here alright and let me go back to the code so yeah I'm setting up the user models so creating the user manager so this when a regular user is created basically saying that the emails required user email setting it as the default field and then okay I'll set it as email instead of user name in the other in the actual user model so let's see so yeah the user manager looks like I'll be using the same thing because it already has users and and by the way this is fairly similar to what it's in the Django rest framework Docs I think it's in the rest framework Docs creating this user manager and stuff so you can always find it there with some more details I guess okay and then let me just look at this okay and then so I have this user class now and here are my fields for the user class and I'm gonna add another field I think and then user name field I'm telling it to use email instead of user which is important for login because I want to log in with email and then custom user manager I'm telling you I want to use this user manager instead of the default one okay so the default string will be email has permission everyone has every permission I don't know I'll leave these alone for right now those are just functions so I can change those okay so is active is admin is staff email that's all good and then I'll have password functionality what else let's see oh I need to do for this particular app I want to have a boolean here that is is student equals models right now volunteers won't be able to log into this site it's just going to be unless you think we need that right now Jared but I was thinking about doing that in the future and right now an admin can add volunteers with volunteer information because we have a bunch of volunteers for our coding school and we want you know everyone to be able to manage their own profiles in this app but I think right now we just really need the students to be able to log in so is student will be a boolean field and the default will be false yeah because when students sign up we'll just set that to true look at the SMS repo readme to see the register section okay can you post a link in the chat for that are you talking about where the front end is the student management system front end okay if student is active is admin is staff that I think those are the only things that I need let me look at is it here no it's so must be in the front end okay let's see groups okay so groups is something that Django gives me so this isn't I don't have to directly set this up on my user model here and I'm gonna be using that for auth thank you Gerardo is it thanks for the cake so I don't need to set that up Django gives me some nice group options later student profile I will be setting this up in my users models and that's going to be a separate model but let's see let me just get users set up first so I got so I got the user here user profile I guess I can go ahead and setup this since I'm in the models and then this will be the last thing that I need to do okay so user profile class alright and let me look at my let's see okay so I need first name and last name and preferred name fields so this is the foreign key to the user because each user can needs to have a user profile and basically I separate these two instead of putting them on the user because these things are really for access and authentication and authorization you know stuff like that logging in those are important for being able to access the site and then these are just information about the user so i'll a foreign key or a one-to-one filled with user cuz each user should only have one profile i don't see a reason that more and let's call this okay so I need preferred name which will be a char field just like first name and last name and then image so actually I didn't have image here but I should have image so I'm gonna leave that I have a profile image and then I'm gonna have let's see discord name because we basically connect discord github code pen all those things for the students because students are continuously pushing code or submitting code on those and they also build their portfolio on those sites okay so let me get rid of this okay discord name will be models dot yeah this will just be another char field and with max length of I mean it's not even gonna be close to a hundred but let me copy this a couple times because I've github username and what else code pen username and FCC profile URL hmm this might be a little bit longer char field is fine let me put 255 for this I really don't know how long it's going to be current level now this will be let's see this will be a char field with options you have to select one of the available options so right now in our classes we have level one where if students are in level one they learn HTML CSS and JavaScript and a little bit of a JavaScript framework either view or react and then in level two they learn back-end so they learn node Express a little bit of and database stuff over a 12-week period so currently we only have two levels so let me do current level equals models dot char field and then here I think I need to do choices is it choices and then pass it levels and then let me make a choices or let me let me make a levels list or a tuple okay with the levels in it so let me look this up real quick so Jango char field choices how to properly use choices field in Jango yeah this is exactly what I want yes it is a tuple with two bulls asked six years ago but this is still the same anyway I think oh it's generating a list but I think the code and the question is right based off of the ones I've made okay so I just need to make yeah they cannot be changed but nobody will be changing these anyway so let's see actually okay so this will be an integer field not a char field so it'll be an integer field and I think I can pass choices to an integer field it could be a dict right I'm actually not sure because I've always used two poles for this so I think I can do [Music] the description level one and then oh wait let me do this okay and then level so it's stored in the database as a 1 or a 2 just an integer but and now that way we can update the names of these later ok so choices levels let me look at Django integer field choices make sure set Django enter interval filled by choices okay so this is the thing these questions have been asked over 10 years ago so let me look on Google and see if it gives me newer questions Django integer field this is from 2017 so this should be up-to-date oh it's generating a list comprehension list zip range okay I think okay I think I'm right so I'm just gonna do this I can always change it to a char field and change these two strings if I need to later ok so they can you can select their current level that's good issues created thanks Jared okay now phone and time zone so let's see phone will be easy that's just I'm just gonna put put it as a char field and then do validation before it hits this not yet not yet one second so phone will be let me just finish setting up this char field so I usually there's a localization library I might use later to properly configure phone and right now everyone is from the US so phone will be easy but if we ever need this to expand to other places then we need to consider how we're going to handle phone numbers so I'm just doing a char field they can enter anything we'll have to change that in the future and then time zone so how are we gonna do timezone I could just leave it as a string for now and then again I might have a localization library to handle standardizing time zones okay so I have the user profile set up exactly how I want so this is probably ready to run my first migration let's see let me make sure so images uploads to profile images so Django will create basically a media file here cuz that's what I put in my settings I said I wanted it inside a media file and then inside that media no media folder and then inside that maybe a folder there will be another folder called profile images where all of these or profile images will be uploaded to okay that's good what else do I want to do okay that's it for right now gender do I need gender that gets complicated yes I do have email so email because that's used for login is on just the base user model here user profile is just all the extra fluffy stuff but they're related so we can pull both for students okay so yeah because I won't need to use email because I can access it via this one-to-one anyways so when I pull user profile I can always access the user email okay so I think that's good all these other ones all the other tables I can add later why don't I run my first migration let's see now I have the database table let's see Python managed PI let me try to run the server first and see if I have any grievious errors oh yes I didn't install this package the for Postgres so let me pip install that first clear pip install this and I think it's going to complain one or two more times because for image uploads I'm pretty sure I need an external package and a couple other things okay so let me see so let me try to run it again so python managed up pipe run server they're gonna upload a profile image okay it cannot import user view set o because i where where is it oh here because i haven't created the views yet that's why i'm importing something that doesn't exist but that's fine so i think that means it's configured properly so let me run the migration and then I'll fix that views file and then I can test out the API finally alright so it's been over an hour already and time just flies by one second okay so Python managed dot pi let's make migrations oh so I do actually have to have an error free app to migrate alright let's go ahead and fix that then let me just get a basic view set from here so let me go into my reasonably productivity back-end app which I posted in the chat earlier if you're just tuning in so you can come here I've been kind of building off of this code because it's pretty similar to what I want to do so far and then it's going to diverge pretty soon but all this user stuff is so boilerplate filled that it's just easy to copy from another project okay alright so Django rest framework so if you use Django you probably just create the views class and that's it or you can use a function you know whatever you want but in the rest frame work you need this serializer so I've already created that and let me just make sure that it's what I want for this project so let me move my face actually if I can make that yeah over to the very edge good hopefully that's better if you can still see my face there okay um so I need this serializer let's see i get user model so i have to define the model in the serializer and we already created that in the models file this where is it the user model so that's going to be my default user model and I actually have to update that in settings telling it where my default user model is and now in my views so every other mom that I'm gonna do like volunteer all the other models I'll have to import but Django because user is special because you use it for us and everything so it gives you this special import for user model so I just imported that instead of importing it directly from the models file to be consistent okay so this is for creating the user right only mid-length okay so I set some password requirements nobody can see the password when they're pulling in from the API and the min length of the password has to be eight characters no other requirements fields email password are needed to create a user I'm also going to put is student here which is the boolean field so you need to denote if it's a student I might be setting that automatically I'm not sure okay so this view basically will use the query set so Ike this is basically lets me do different requests like a get request and get all the user objects back and I think I'm only going to be using that for okay so there is a username and password or an email and password option I'm not going to set up github auth yet but I just want to get this authorization stuff set up first so people can log in via email password or via github if they want I know I know I'm getting to github but I'm not there yet okay so no know what I should I not let them login at all that's gonna change the whole way the whole planning for this I think they should be able to use an email password if they want and then have the option to do social login via github okay so you need these three things to sign up extra I think that's it so user dot objects not all so wait why am i importing user here I think I can just use this so I'm gonna do this here too because I'm being inconsistent with myself so and now I don't need this to import the user model at all because Django's doing that for me now one more settings I need to set the default user here so okay I don't think it's just using the default so I need to add a user setting here and oops let me go to my config settings dot PI file and there's one option I can't remember what it is okay so auth user model this is what I need to do okay of course yeah I have to do a lot of stuff alright so here I'm gonna do users dot user which is referencing my users app and then the user model on that app okay now it should be ready to migrate let's see if I can run a migration alright so I'll do Python manage PI I was hoping this would be simplified less back-end in front-end code easier for the students to just know create a github account yes so much config that's really how setting up django is one account for all the stuff they need yeah and I agree but I want to give I want to set up this user all stuff because eventually like version 2 of this app volunteers will be able to login maybe auditors I don't know but I want the email password login option and then we want to have students sign up with github admins admins can also add users into the app as well so they can set up a temporary password for the users so let's see make migrations python managed PI users user profile image cannot use image field pillow I knew there was another thing okay so pip install pillow that's for image reusing image uploads because that's not in Django by default okay we can force I mean we can just not give a front-end option for username password but from the admin area you'll still be able to use a user or to add a user with a username and password okay and let's see okay you're like okay that's fine I guess what did I just do oh yeah let me try the migrations again make migrations please work yes awesome sweet so let me look at my new migrations so I got my initial migration and then I got the migrations - these are basically creating the tables for me so it's setting up the migrations for me sweet so now let me actually do the migrations run them so Python managed by migrate and that this also is running the built-in migrations like admin content types the built-in django migrations as well plus my migrations okay I will I waited to do the migrations because with Django it's just better usually if you do if your first round of migrations includes setting up users because that seems to be the hardest thing to do in in Django and also why last time I had to revert so many migrations delete the database and do all kinds of funky stuff okay so now let me cross my fingers and try to run the server run server suite okay let me go to port 8000 localhost 8080 ax 404 but you can see it's telling me that I need to be going to slash admin or slash API slash b1 slash users so let me go to slash admin of course I don't have a super user created so I can't log in here yet but I'll do that in a second okay let me go to the API see if that works v1 slash users awesome so this is just an interface that Django rest framework gives me for development and now cool I can add a student here instead of using a rest client to make API calls I can just do it straight from this form of course this form isn't going to show up on the front end okay okay so get I can do get but of course I have no users yet so let me add a student user real quick let me call it student 1 at example.com that's another thing I need to set up is email management which is actually much here in Django versus other frameworks let me just add a task here email management setup I'm probably gonna use mailgun for it it seems to be the easiest thing and because that other thing I tried what was it SendGrid they thought I was a spam bot and just would not for the life of me I could not set up an account with them okay I'm gonna set up a password oh you can see it ten characters so hello moto ten and then I'm gonna just check off his student post Oh unexpected keyword argument is student hmm I tried fiddling with Django several years back quickly realize it's not for me now I'm happy with spring okay cool I worked in spring for like seven months at a company yeah I think well they both have that verbosity but spring is more so because it's written in Java of course in Python just a simpler language what do you like better about spring by the way okay let me figure out create user got an unexpected argument is student so I'm missing the is student somewhere because I added it here in the user class so let's see email custom user manager let me see if let me look at my views so I haven't set up correctly here it's also in my model so I wonder if I need it in my model manager I think I do need it here Oh in serializer am i doing it wrong get user model fields email password is student extra arguments that's fine and then I pass all the validated data to create user which it's throwing an error here when I'm running this create create function so I think I need it here don't die in the user manager user equals self top model email set password and then saving the user so now I don't know you know let me see it was my error so got an unexpected keyword argument I'm just gonna look great user I'm gonna look this up unless someone else has an idea what I'm doing wrong so let's look at Django rest framework got an unexpected keyword argument well to be honest I use spring boot rather than just spring it makes life so much simpler but with Django I felt like overly complicated very soon especially when you scale up so I haven't scaled a Gengo app to be very large yet I mean like who used Django reddit in those companies so I don't know how they're doing with it but it's it gives you so many things out of the box like authentication mail services database your migrations there's just so much oh the admin interface is probably the best feature of Django so if I need an app with an admin interface like for a client especially as a freelancer I think Django's probably the best fit for those kind of apps let me see if something better on Google serialization error custom user model wow this is hard to read what okay going back going back how to solve Jiang create user unexpected keyword see there aren't a lot of questions and answers for Django rest framework specifically so does it take secondly create user doesn't take all of the field names its arguments it only takes user name email and password again you need to set the other fields afterwards yourself okay so I need to set it afterwards so I wonder in my where as in my views am I supposed to do it here in this custom create method like you said in the serializer because I'm getting it so this is just for the get and some config options and then in create when I'm actually creating the user I'm getting all the validated data back so but it should pass all the fields let me see this is heavily lacking context to this answer creating a new user and then set password mmm yeah this is for I would do it without the Django or without Django rest framework oh wait here's a Django rest framework question let me zoom in [Music] unexpected keyword base name they mentioned that oh that's not at all ok let me look in the docs take a look at the network tab to see what is being passed to create user let me see all right let me try again let me do post so let's see I get a 500 so let's see I mean it's passing his student yeah as true and then name is student so unexpected keyword argument is student so it's not expecting his student so there's some kind of setup that I need to do here for the extra field let me see in Django rest framework so where oh where would it be in the API guide I wonder if it would be in maybe serializer do I need to set it inside the create let me look in serializers okay importing serializers okay I think I'm gonna look directly in their user serializer because I think like the comments saying on that Stack Overflow post is just expecting email what is it email and password both create and update methods are optional on the serializer okay do I need a custom save method then because I have create which is creating the user validation field level validation I wonder if it has a user sometimes you let me zoom in here okay so sometimes you'll want to view your code to be able to inject additional data at the point of the saving instance this is additional data might include information like current user the current time hmm it's your Eliezer dot save no let me look in the create method is there no it's not showing me okay writing create methods for nested representation okay so because I'm overriding the default create method here and it's showing this this is the same thing I'm doing so create validated data Oh I'll be wanting to do this to create profile objects that create user profile eventually huh fields username email profile profile serializer okay let me do get here again yeah I don't know there's another I can also check out the Django rest framework let's see user creation they had a they have documentation on it dingo rest frame of dog authentication and permission user authentication tutorial let's see so authentication and permission adding information to our model adding endpoints let's see adding information to the model so okay so it says now we can have a save method to our model class I'm wondering do I need a custom save method I feel like this should work okay [Music] import user user serializer so associate associating snippets with users okay I don't want to worry about permissions yet let me go back oops let me go here user registration create a new user create ok user serializer set password why isn't accepting this extra field it's not accepting the extra student field and I mean it's in so his student is here so it's in the database already default is false I mean what I could do right now is go into my not my models but my views since it has a default already just so I can move on I can take it out of here and okay yeah I think I'm just going to do that and then the in the in her face I'll just have to add is student okay so let me try to create another student Oh user what that email already exists what the heck so it already exists so it worked so it worked to create the user but it was giving me back a 404 page and a 500 error because something was happening after I created the user that's weird so student to at and now let me log into the interface and see if that user is created with yeah let me log in and see if that user was created with um with the student the student flag is true so now I should have one as true and two is false and to login to admin I'm gonna have to create a super user so I'll do Python managed up I create super user okay and the email address for the super user I'm gonna put one at example.com password okay created the super user now let me run the app again cool and now I can go to localhost 8080 when at example.com hello oh I just gave you my password okay it's just local Doe so it doesn't matter oh right right so I didn't register users in the admin area so I can't see that groups like I said before is something default that Django gives me so to use user because I created a custom model for it I have to register this in the admin area so let me close those now in admin dot PI I'm gonna have to register my user model I might be able to copy what I'm doing in here so if your let me post this link in the chat again I've kind of been using this repo that I created before as a reference because it's also Django REST API but I'm going to go into apps let's see utils no no what am i doing users admin ok cool so I set it up in the admin area already that's perfect I didn't set up the profile but I can do that in this stream so let me just copy these and then ok so let me let's look at this so basically Django ok so I can just set admin dot site dot register I need to register the models I want to be able to use from the admin area in this admin dot PI file so now I can use user and user profile but I want to make them custom so that's why I'm passing in these custom objects so it's not just registered with all the fields I want there to be all these other options like sorting and how I want it to display and dividing it up into field sets and stuff like that so let me see if this works umm let me go back to admin yeah so my server restarted after I did that so I should be able to restart sweet so now I've users and user profiles so if I go to users I can see in the table email is staff in is admin okay so let's see those three fields so that's from this list display option email and staff is admin I also want is student here so let me add is student to that table now if i refresh it should add this option sweet so no there none of the students that's very weird okay that's fine because now if I go into a student let's say student 1 ok it's not giving me that option let's see permissions fields is admin is stuff ok so I need to add it here so I see that option so there is a lot of config and Django isn't there so is student so let me add that his student option sweet so now I can add his student save and now it's student ok good so the admin can always update that all right so hi Bella how are you ok so the admin is now set up for this filtering ordering oh yeah so filter I can filter by is admin that's basically what I added here list filter so I'm going to filter by is student or is admin so is student and then ok so now if i refresh that should be added to my filtering options ok so let's click yes and now the table filters by his student now buy is admin okay so is staff this boolean Django gives me this by default and that basically means that this users allowed to log into the admin interface and is admin is no administrative privileges for everything okay so I have that set up do I want search so you can search by email the ordering is alphabetical order by email okay so now I should set up the user profile here let me go into user profile so into this and see how it looks okay so I don't have any user profile so if I add one okay I can associate it with the user I can add all of this information and then save it okay so that's good enough for now I guess let me go back to my dev tasks and see where I'm at so I set up my user model let me drag that to done so Oh should I do next so let me go ahead and setup some of these other models and then I'll get to all of the other config stuff I need to do so let me set up the certificate model by the way because I'm using the Django rest framework and the router that comes with Django rest framework I can look at any of these users basically by their ID so I can make a get request I have HTTP request options just the router gives me all of those options which is nice okay so that's good I do want I actually want the user ID returned here as well so let me see let me actually look in the request and see if the user ID is being returned here just so the users request let me look in the response hmm Oh document where is it go away go away was that doing I thought this was getting the JSON data but it's getting a content type HTML so I wonder if it's just sending me wait let me preview it yeah so it's just sending me this so it's not actually sending me the JSON it's sending me this as HTML so what if I want it to return the ID to me here like because I don't want just want the email I want the ID to so why won't it - show me the ID I think I might have to change that in let's see views so feels so fields the ideas automatically generated so I don't want to add it to fields here but I want to get the ID back so how do I do that and let me see if I can look it up again so Django rest framework get ID in let's see or maybe it's return ID return ID with get request returning ID value after object creation so after a post request and I'm already doing this in my other app so let's see yeah that's not helpful how to return ID oh I think it does return the ID automatically get the idea of the object recently created let me try this out in an actual rest client so I'm not getting a whole HTML file back so HTTP colon slash slash localhost by the way this is the rest a rest client just in my Firefox that's literally called rest client but it works the same way as postman and all those other ones okay so HTTP I see localhost where is it running eight this API is running on a port 8000 slash API slash v1 slash users moved permanently okay well I got this back I wonder if I need to say let me set content type just in case even though it gave me back JSON but I don't know if so I guess it won't help anything but application JSON okay so why am I not getting the ID back and returned I need to return the ID so Django hi Sergio Thank You Django rest framework man why is this so hard what don't you think when you make a call for objects in a database to be returned than you want you just naturally want the ID with those because you do so many things with the ID on the front end and even in the in the URL so I mean where is it where's it here I want to do user slash users slash user ID how can I get the user ID if it's not returned here this doesn't make sense am i doing something wrong a Django rest framework return user ID with get request is this the same thing I typed in before I don't know Django restful api here how do you get user ID with Django I like to look at any question it's pretty relevant I've found even if it's a within the last I'd say four or five years if it's before that it's way too early or they're probably using Django version 1 which isn't as relevant ok so class album is okay so they have this model and this serializer and they want to know how to get the user ID returned Django rest framework sterilizers uses a context to keep those things it is used to find out Association host name with hyperlinks serializers documentation here by default generic view to add the current request which means you're able to do okay so I can so you can make a custom basically it's saying you can make a custom function on a serializer to get whatever information you want let's see of course here he's not directly calling the asker of this question it's not directly calling the users and point with a get request like I'm gonna be doing he's trying to use this other model to get the user ID which is a foreign key I know that's the artist so maybe artist is the user I don't know let's see user ID so they're getting it based off of the request but I just want I just want it sent back this all I want I just want it sent back with a get request return the ID of the object can API token auth returned user ID I haven't set up token off yet how to write an API in three lines of code it's a lot more than three lines of code okay hi how are you I'm building a REST API in Django using the Django rest framework for our free coding school the links in the description to this repo so you can see the readme and what I've been working on that's been almost two hours now so I'm basically set up the users and the all the Django config the user models the user profile model and some of the admin interface and now what I'm trying to do is right here so I have slash users if you can see that slash users I'm getting all the users back but I'm only getting the email I want the user ID returned and I don't know what I'm doing why it won't return the user ID so fields I wonder if I need to I need to have set it somewhere in the user serializer don't I query set I have the query set here which should return all the information so this query set in my view should have the what is it should have the ID the email that all the flags like its admin it should have all of that information but why when I make a get request am I only getting email so fields here I feel like this is the this is just for the form I think this option let me see what it does oh if what the heck that was all I had to do okay well thanks for making me rubber duck it again because apparently you helped me figure it out okay so fields its returning ID now it's not returning password because I set that as a write only field so it doesn't return that here man an ID I guess it won't give me the ID in the form because that's that's just a field that's generated by what do you call it Postgres Postgres generates the ID for each row sweet awesome I'm so happy about that what was that yeah close all this close that cool that's exactly what I wanted and now let me set up some more models and I'll go yeah I'll set up some more models and I'll set up the admin interface is for those models first though let me push the code so if anyone wants to see the code they can feel free to do so so let me do it get status first oh is that a git repo cool so actually since I created the repo and it has files in it already let me think because this repo has files in it already which I usually don't do I'm gonna need to merge get histories that aren't the same so let me go to my local file and delete I don't have a readme here so let me see what happens let me do it get in it getting it initialize to get repository so git remote add origin and then I'm going to add the SSH clone with this or not clone but okay so get remote - V okay so I have my repository remote repository set up as origin so let me do it get status now I wonder if I can get pull oh wait I have to do git pull origin master fetch okay well let me do get status now so I have get ignore so this V is code folder I need to ignore that apps config management everything else looks good so let me go into my get ignore and add add it to the end here okay so I should be ignoring that and let me just because this haunts me a PI cache good it's in my git ignore so I will not be adding PI cache files all right so let me do another get status all right vs codes not in there now so I can do a get add just add everything get commit - em first commit and now before I push I'm gonna have to do pull so already up-to-date so did I I don't even know oh I pulled in my readme file already what am i doing okay so now I can do git push I'm gonna set my upstream as origin master okay and now the code that I wrote for the last almost two hours is live let me refresh this now sweet so now if you go to the repo in the description you can see all of the code updated as well as this whole readme with the scheme and everything cool so before I go on I'm gonna look at these issues because someone else created these not me handle group projects that's something I'm going to do later projects you are proud of what does that mean Oh allow student to distinguish or highlight a project or projects they are proud of could be a boolean or an object could just skip this and have their portfolio be the source of truth okay yeah because eventually if you look in the readme I'm gonna scroll to the bottom I have version 2 down here where students will be able to have public publicly viewable profile information with some of their projects and stuff on there did I look at the other issue I looked at two issues so yeah so they'll have public profiles so then it would be important thank you this issue I created so I know it's in this just issue yeah this is just me github so los did you read the group projects oh I guess I didn't carefully read it I just looked at the title okay relay a submitted project to multiple students let's see input field with URL to project students that worked on this project okay students have control on their profile to paste in URL to their project but they should not be responsible for adding or removing other users from a group this could be derived automatically relate a submitted project to multiple students hmm did you read it yes did you read it no just the title yeah okay sorry you caught me you caught me I thought I read it I got confused alright okay but I'm not at projects yet so I will do that when I get to projects okay now I just need to blank it create a whole bunch of tables and then I guess for right now I'll set up URLs for them I'm gonna have to update the URLs especially since some of them like let me go to it down to my API some of them will be you know I'll have a resource and then the item and then another resource so I'm gonna have to configure stuff like that a little bit different but I'll set that up later we can have slash projects and slash team projects okay okay the projects projects are coming okay um let me sum this is the Genco where is my other one okay so in users all right let me set up my next model so I'll set up the certificate model next so what is in the certificate model I just a lot of these are pretty similar so certificate is just name description and then some of these are going to have created at updated at I'm still going I'm gonna take a break pretty soon though and get some coffee track my walking for a minute so I don't get too far behind today my Apple watch okay but I'm gonna set up a couple other apps and models first so I have this users app so for all of these different types of things I'm gonna like projects attendance mmm tendons might go with students let's see certificate so I'm wondering because I had needed to set up an app I shouldn't set up a whole certificate app should i it should be something like maybe I need a student app and I'll put certificate in as a model in the student tab because I'm not going to create a whole app for this yeah I think what I want to do is create a student app and or no maybe a student management app okay so what would I put together what goes together like like with like certificate I think certificate should go with project right and then student should be a separate app where I put those so what would I call an app with certificate and student no no I'm getting confused with certificates and projects and lectures certificates projects and lectures would that be let's think utils what would I call that certificates lectures and projects let's see Python manage PI start app oh well I need to create the folder first with just like I did last time so make directory inside of the apps folder I guess I'm gonna call it utils no one seems to have a better name for it so that's what I'm gonna do so utils and yeah that's fine I can always change it later alright and now I can Python manage PI start start app utils Oh basically I want to put these lectures lectures certificates and [Music] projects in the same app in the same place because I think those three go together unless you think I should make a separate app for each one well let's think of how we want to arrange the URLs I only wrote out slash certificates but I'll probably have I guess I'll have slash projects okay so a Django app is a portion of the project that he'll handles like users gives me all of these files associated with users so I get views which is what I want to return to the client all my URLs associated with it let's see ma and then my model so any i'll make any models associated with user so user user profile that kind of stuff associated with user but for let's say certificates i could make a whole app just for certificates and then have urls model admin everything just for certificates or I could kind of combine a couple and put a couple different things into one app does that make sense alright maybe maybe what I want to do then is just create separate apps for now and I can merge them into utils app later if I want if that's confusing so let me just create a certificates app then I'll keep utils because I'll be making a utils folder anyways so let me make certificates because I think it's what I'm doing is might be confusing so let me just do it this way so Python managed dot pi start app and then this will be the certificates app and that will be inside the folder app slash certificates okay so it created that app for me now so now I have this whole new folder just for certificates let me close these delay oh delay test oh I guess you can hear the little popping sound anyway how much is the delay how long is it nine point nine seconds ah that's not not great I tested my Internet today I'm plugged in to the router and I was about a hundred hundred down hundred up which isn't what I pay for but you know I don't know I'm gonna test every day this week and see what the average is and then call them if it gets slower but I think the connection is fine it's probably just YouTube that's causing me to like or the comments to like a little but I will be on twitch soon I'm slowly figuring out the platform so that should be better for comments okay anyway what was I doing in the certificates so in my certificates app let me first create a new file and I'm gonna call it URLs dot pi cuz I'm gonna need that and then in my settings I need to add the certificates app so let me go into settings and my apps so I have users I'm gonna add certificates okay cool and now let's see what should i do first let me add the certificates model here so so with users when I did my models I had to create this user manager but that's just because I use users for auth so now all I'm gonna need to do is create a class for my certificates model so I don't need a manager and all that other stuff so I can create a class called certificate then extend from models dot model okay and now I need to create this model so what did I want on this let me go to certificate so I just basically want name and description so name and description and [Music] oh yeah and then I'll do create it and update it at and I'll make I guess for right now let me just add these create it at and update it at and I can always make these into a plug-in later okay so for name this will be models dot char field and then max length will be a hundred okay in description will be models so this could be longer so I'll get I'll save this is a text field so there's no max length to it anyways only admins are going to be creating certificates okay so created at so this will be models dot actually I'm gonna put these because so many of my models are going to need created at and updated at so I think what I'm gonna do is go over to my handy other repo this reasonable productivity web backend repo that I keep posting in chat and I think so if I go to apps utils I have this model that I've been importing and using so it's what do you call that mixin so the time stamp mixin updated at updated by and deleted by mmm-hmm yeah that might be good information to save created at updated at deleted at created by so deleted at would work about was doing soft deletes which I think users and Django might be soft deleted I'm not sure but nothing else I'm doing is soft deleted right now so I'm just gonna set up the time stamp time to time stamps so first let me set up my utils app that I already created a folder for so Python yeah oh you have them on every record at work that's a good idea maybe a version too I'll do all the rest of those okay so Python managed up pi start app start app utils and then in the utils folder so Apps slash slash utils okay it's clear okay so let's see I'm gonna use this same thing so basically this you know models that date field self-explanatory auto add now only adds when only adds at the timestamp when the items first created and then updated at this adds a timestamp auto now I know these words aren't intuitive I think but auto now adds it every time it's updated so maybe it is I just keep forgetting what they are oops no don't close okay so now let me go to utils and add that yeah it's better to just do it now instead of waiting and then never doing it okay so I have my timestamps oops okay now I have my timestamps mix in so now I need to import this so let me look at where I'm importing it into let me go into tasks and I'm pretty I'm importing it into my tasks models yeah I'm importing this time stamps there so let me look let me close this so in my certificate model so let me import time stamps and then I need to inherit from time stamps time stamps from the time stamps class so I think that will work let me just make sure I did that correctly time stamps okay okay that's good so that should be good and let me real quick let me register my model in the settings so because I just added that utils model so let me for some reason I like having utils at the top so let me register utils I've access to it as an app and then that should work so now if I run let me migrate now that I have their certificates model so let me oops Python managed PI make migrations okay cool so made the certificate migration let me check and see what that includes before I actually run the migration oh wait that's users Oh in here okay so cool so I have created at and updated app from my mixin that's that's very good that's exactly what I want alright so I did migration solo let me actually migrate before I take a break here so let me do Python managed by migrate okay so it applied that migration that I made awesome so yeah so I'll set up because right now Oh my server is not running so right now my admin interface I can't see the certificates yet so I'm gonna take a quick break and I'm gonna add certificates in admin and then set up the whole thing so URLs views to be able to get certificates actually yeah I'll need to get a list of all certificates so I will set up the URLs and views for that and the admin area and then just bang through all these models when I get back I can go ahead and push my code though if anyone wants to look at it so git commit what should I call this second commit okay that's fine oh think of better commit messages later alright so I just pushed my code I'm gonna say let me set a timer for 10 minutes take a 10 minute break and then I'll come back and code for at least another hour yeah thanks for watching I'll be back in 10 minutes you hi everyone I just need a bagel no cupcakes yet I was just really hungry all right so I'm gonna wait just a second and then jump back into the project yeah who's who's still live with me supposed to comment in the chat if you've been following along alright so I think I've that's enough time let me just first look at my task list so I have all these tasks in my projects born on github okay thanks Jared good good to know I'm just talking to myself all right so I have all these tasks on my project board in github and this certificate model yeah so I kind of said create certificate model which I already did but I kind of meant that I want to create the whole certificate app the admin setup all of that stuff are included in this one task so I'm gonna go ahead and do that real quick before I mark that task is done let me run the server first so python managed pi and then run server cool no issues and let's see in the admin interface I want certificates to pop up here and then eventually I'm gonna customize this admin interface but I'm just gonna for today I think I'm not going to change anything I I might actually so when the front-end is set up later I'm probably gonna copy the styles from the front-end into this admin interface so it looks somewhat coherent or something it looks the same basically okay so I have certificates let's see models that was pretty basic name description' created a updated at certificates I don't know what's going on but I am watching oh well welcome to the world of coding Kumar you can look at so this repo here that I've been working off of today student management system it's linked in the description below hi so mesh yeah everything is linked in the description below and I've already pushed code twice today so you can see everything I've been working on here let me refresh actually so I think yeah I just pushed thirty-six and fifteen minutes ago so you can see all the updated code if you have any questions as I'm going along just ask me and you can also see if you go into the project's board here you can see these dev tasks that I'm working on and pulling into the done column as I finished them so I'm in the Django admin interface and let's see I have users now I want to set up the certificates model here so basically what I need to do and I'm gonna copy some of the code from my other admin PI file let's see I don't need all this stuff there are only two fields really on certificates so all I'm gonna copy is this let's see and yeah I won't even need this so let me copy this and I'm gonna update it in a second and then I want to I'm gonna have to register certificates so let me copy this okay now get rid of that and put that register down here oops register there there okay so now let me slowly update all this stuff so from models the only model I want to import here is the certificate model that I just created auth admin I won't be importing any of that stuff so let's see certificate admin so the certificate admin inter interface so this should extend from what what should it extend from let me see hmm let me actually go into my where is it where is it example repo that I've been looking at did I close it I might have closed it let me see yeah I think cuz I I like hitting command W all the time so I closed it [Music] let me look in tasks so let me look in the admin interface and tasks and okay so it's extending from admin dot model admin so that's the same thing I'm gonna do here oops admin dot model admin ok already importing admin now I need to okay I'm in dot sight that register I want to register my certificate which is my model name and then the options for that model that I'm setting on certificate on the certificate admin class I created and of course I need to update all of this stuff so get rid of all this so in the table display let's see I'll just put name I guess well no I won't I'll put more stuff but let's see list filter I might not do a list filter so let me see how this looks right now save oh I have some kind of error the value of Lists display must be a list or a tuple okay so I just need to add a comma here to make it a tuple all right so let me refresh here cool so I have certificates now so I can go in here add a new certificate name completed level 1 I guess description Congrats I don't know all right so now when I look at the list of certificates in the admin interface I can only see the name here so I want to see the created at and updated at fields also so let me add those let's see creative at and updated at okay cool so I have those and I one more thing is I want to be able to search so if I go into my users or is it my users right now I can search by email address so I'm gonna set up the same thing I'm going to add that search box to certificates as well so let me go into the users admin search fields so it's a search fields option so let me set that here too so search fields and this is also a tuple so I'm gonna say yeah name that's it okay so nope oh yeah it worked okay the server just had to catch up all right so I have that four certificates now but on the front end there is no URL for certificates so I'm gonna have to add URLs to this and I'll need a serializer and a view and to update my urls file as well so let me start off with this because with with Django this you are or with Django rest framework this URLs file is almost identical because I'm using the default router from the Django rest framework so I'm not doing much with URL patterns right now so let me just basically copy this into this URLs file in my certificates folder and then I'm gonna make a new view set so I'm going to call this certificate certificates or certificate what was that called user view set so I guess I'll just call it certificate view set okay oh yeah and then I have to update that and that's pretty much it and now in my views I want to let me look at my views so the user views are a little bit special just because of like the password and creating new users and stuff but I think I can just build off of that I don't need to use this off module get user model for the certificates so I'm just I just need the serializer and view set so about my model I will need to import my model that I just created so I'm gonna import my certificate model up here so let me import import no no no come backwards from dot models so this models file in the same directory I'm going to import yeah the certificate class so import certificate cool so and then here I'm gonna rename this so this will be certificate serializer and then this will be certificate view set and then the query set won't be the user it'll be certificate than the certificate model okay oh yeah and then I have to set the correct serializer as well okay oh yeah and create I don't need to do a custom create because we're not doing anything special so extra no I don't want extra so all I want really here then is the name and then the description really and created at an updated at fields are auto-generated so I don't need to have them here but actually I might want to see them on the front end right so I should have created at and updated at I don't know why I would want to see those on the front end for certificates but I might okay so I D let me see how this looks so oh yeah I didn't set up the URL in my main router so let me go to my main URLs file and config this will be API v1 slash certificates and then include certificates yeah include app users app apps certificate so to fit kits I did call the app the right thing didn't I certificates yeah it's plural okay just making sure all right let me see if this works now oh it doesn't like something I did path API v1 certificates includes so something is wrong let me open that file oh I'm not I didn't have a comma so let me just add commas there okay my server's running again unable to connect okay it's connecting cool so now let me try that new certificates rap that I just made and awesome I can see the certificate that I just added and then if I want to add a new one I can just add name and description and make a post request so let me say completed level two and then yeah just anything okay so post worked and now let me get again and cool so I get these certificates and then again I can do the certificate slash certificate ID so one and it says it's allow get put patch delete on this item and I can always disallow those later okay so that's basically everything I wanted to do it works in the admin interface and it works as an API as well all right so how are you guys following along how's everything going it's 140 here I have another hour or so free so I can just keep going I could do I mean I could do this every Sunday just another hackathon okay so let's see oh yeah in my dev tasks now that I setup certificate model try oh you're trying to fix the is student field that would be awesome thank you are you saying I should try to fix it all right so this waitlist model so this waitlist model should be only for admins to see and to enter because so basically when we created this coding school we were worried or I was worried that we wouldn't get any students interested and then all of a sudden we had like ten times as many students as we could accept so we had to implement a waitlist system which right now is in a spreadsheet so we want to be able to see this and manage it from this interface so right now you can enter it in through the admin interface and then eventually I'd like to be able to upload a CSV file or maybe do group bulk updates or something yeah so let me just create a basic model for that right now let me see so yeah let me create the model and then make it work in the admin interface and then I'll push code after this one so let me let's see close these apps wait close that close that all right so I need to create another app and I'm gonna call it waitlist so let's see python managed pi let's see Start app oh wait I keep forgetting I need to make a folder first inside my apps folder so I'll call it waitlist it's not going to be plural just because there's just one waitlist okay so now python managed dot pi start app and then it's called waitlist and it's inside the app slash wait list folder yes that would be awesome wow did you figure it out yeah we'll look at the PR as soon as you make it okay python managed up PI star tap waitlist ops waitlist okay and now I should have this new app waitlist app loops waitlist let me go ahead and make the standard URLs dot PI file and I'll add this app into my settings under installed apps so let me add waitlist here okay so I have the waitlist app now let me set up the model here and I can copy let's see what can I copy from I'll copy from the certificates one that's a pretty simple model here hi how are you okay so this is a pretty simple certificate model and I'll just rename it to be oops well I guess I guess I should call this like waitlist because this model is just one person on the waitlist thank you glad you like it so this is just one person on the waitlist so I can't call it the whole waitlist so I need to call this something like wait list item waitlist person I'm doing well like I said at the beginning it's my birthday so feel free to send me cupcakes if you want cupcakes cake anything sweet okay wait list should I call this waitlist entry that could be just one individual waitlist person I have to pick something wait list I can always rename it I guess waitlist entry and all the model stuff I do want timestamps which is especially important here cupcakes thanks for more cupcakes Jared all right um let's see what was I do oh yeah I need to look at what I actually need in the model so looking in the repo if I go down to the schema where is waitlist here first name last name email and notes so I have email here and the name because these people are not logged into the app they're just thank you these are just people that we enter in so we keep track of them kind of on the wait list yeah so first name last name email notes so let me change this so I'll do first first name last name and then email and notes okay and so first name is yeah it's a chartfield last name else is also a char field emails so email will be models dot a mail thank you I don't I don't know you'll have to send an emoji a virtual cupcake I've been getting virtual cupcakes all day let's see email is I think it's called email field isn't it it doesn't seem to be auto completing let me go back email field max length I don't even know if that's right let me look in user cuz I am using it email over there so let me go into models yeah models dot email field I don't know why that was not I guess populating I want all the same stuff because there's no reason to not have a unique email on the waitlist max length and verbose name yeah all of that stuff is good so let me do the same thing here okay that's all good and now for notes this is going to be a text field because you know people can type in however many notes they want text field okay thank you ooh Donuts donuts sound really good right now there's a who was from Boston earlier this is place in Boston called by Chloe and they just have the best food they've won in Seaport one in downtown Boston and one at Fenway Park or they have a couple I don't know but they have the best dessert and doughnuts ever they're just so good and of course they have Boston cream doughnuts yeah anyway so email address like okay so text field so I think this is all done for a waitlist entry and then because we're using time stamps or extending from time stamps I don't think you are jarred but that would be cool if you were import time stamps yes so we're getting created out updated out field so let me go ahead and make this migration so I can set up that table in the database for waitlist let me see let me do Python finish up pie okay thanks yeah you can comment in the chat if you have any questions or want to follow along join me on discord and we can chat more there's a discord link in the description below Python managed up pie start app what was I just starting now I'm not starting an app actually I am I guess I am distracted making migrations okay so I made this waitlist entry migration and now I'll do Python managed PI and apply that migration with migrate okay so now I have that setup and now let me go into the admin and set up this admin area and this is I think it's going to be pretty simple just like I did the not users but certificates so let me start with that as a base so let me import this waitlist entry model and then let me do waitlist entry admin and then here I'll do ya my model is waitlist entry and then this is waitlist entry admin so I'll register that with the admin and now I have what do I want to display let me get rid of these I might have wanted those actually uh let me see actually so I have first name last name email and notes so let's see I I think what I want to do is have a created at field on the table and then search field I think you can search through first name and last name I guess last name yeah let me see how this looks let me run a server real quick so python managed dot pi run server oops so so it's not happy with how I set up the admin area for this learn some beginner things first sure yeah if you join my discord you can recommend some topics or some live streams that I should do I've been thinking about doing some intro live streams like just come on and you know do an intro to JavaScript for an hour - yeah so let me know let me know what kind of topics you want hi Andre okay so Python what am i reading apps that wait list what error is this the value of list display zero first a name which is not callable hmm oh oh right because I don't have name here so it's first name and then let me go ahead and add last name okay so that should be correct yeah my servers running okay now let me refresh this and now I have wait lists and wait list see Django does this they will add an S to the end of everything to make it plural so because models are singular but it just adds an s to make it plural here so I need to set the verbose nem and tell it that in English it is ie s not just s so let me see how do i code an ecommerce store that works with Shopify use tail-end so Shopify well it depends if you're using I think Shopify you can run it yourself or you can use their Shopify com they have this templating system so I haven't used Shopify in years but they have this templating system called dot liquid that was a lot for me to figure out so I'm actually not sure how I would add do an e-commerce store with Shopify yeah I haven't used choppa fine so long but as a CSS I remember the CSS was kind of easy to do but it was the rest of the templating associated with the store that's really difficult I guess in their templating system and maybe it's different now because I haven't even touched it in at least four years so anyway let's see weightless config use what was I doing oh yeah I need to set the verbosity so how do I do that let's see Django models thank you thanks surf tech I'm using liquid only problem is I'm getting tail link and file yeah I really don't know I don't know enough about Shopify config to be able to help with that sorry jingle models oh yeah how do I set the verbose I think it's just like verbose underscored name oh yeah verbose name plural I think that's it wow this is hard to read um I think this is what I want though somehow I got that let's go to models then in waitlist so for weightless entry I'm gonna add is it on models let me just open that again so child models that model oh yeah I need to add a mate a class here so class maida oh yeah don't need that and then add verbose name plural and this is going to be wait open it one more time okay all right so I'm gonna say wait list entries instead of YS it's IES all right now let me refresh that sweet so now it's spelled properly please check the fourth issue oh cool awesome just one second okay so wait list entries is good let me add a wait list entry real quick so Jane Doe Jane at example.com and Jane is waiting for a level-one save okay cool awesome and then it's searchable and let me just before I look at that issue let me make filterable now I guess this is already so I can already arranged this by date so I don't need to filter anything there I'm just gonna leave that as it is cool so let me look at the issue okay so code Jango and the chat just added an issue here fixing a problem ahead earlier so in the users views dot PI file from rest framework import okay class maida is student so you have extra kwargs commented out or just be in the users list with a type of waiting or something no because the users list is just for logging into the site and the wait list people aren't logging in so when they become a student they can I mean unless you want people on a wait list to just register just anyone who wants to wait but they aren't really a student yet so I was only letting students log in students and staff okay it's good we're solving all these problems live okay so why did you can I ask code Jango why you commented out let me zoom in this extra field is extra keywords kW arcs because I have the password I have these settings on the password that I want oh you made some comments here is student is a custom field and a user model so this field needs to be saved after the user is saved okay is student validated data dot pop is student user okay so the user saved and then you save the is student on the user cool so let me try that so I guess this kr kW args isn't part of the solution anyway so let me see let me look at what I have right now thanks for solving that issue okay so users let me go to views then and in my so def create so in here let me see okay so it's the same as this line is the same that I had so I'm creating a user passing in the validated data okay so I'll get rid of that first I'm removing is student from the validated data then I am saving the user then adding his student back then saving it okay cool that looks great thank you let me test that out now um so let me okay the server is still running and good I saved the file so let me go to the users here so users and oh yeah right right I need to add is student here that's what I need to do so let me add that back here so is student so that way I get it in the form cool so I'm getting it here and I'm also getting this checkbox for a student here so let me add an email address let me add marshal at example.com password is the same student check post sweet awesome thank you yeah code code to Jango just resolved my issue you basically I guess cloned cloned my code locally and figured it out let me give an emoji party and I'm hurt okay now I will close this issue sweet thank you so much for that okay so yeah I'm happy about that okay so that's figured out now that wasn't in-depth tasks though okay so I have waitlist model that's not going to show up on the front end I can already interact with the waitlist on the back end Jarrod's saying that waitlist person should be a user type but similar to having a type of student but the thing is is a waitlist person gonna log into the site because we're just adding all these people to a waitlist right now I mean we're doing okay let's let's stop for a second this is version one like MVP version point one you know just getting it working so I figured just having a waitlist table would be okay for right now okay thank you thank you yes sweet okay we're done with that okay so let me set up these models and then some of these later models are like really so there's different relationships between models these ones have been easy so far because I haven't set up any any like inter model relationships so let's see and probably gonna be on another 40 minutes so let's see how many more models I can knock out so lecture on projects these I need to create models I also need to create the admin interface and what else what else I need to oh yeah I'll need to be able to pull these into the front-end so also needed URLs and stuff for those so let me start with the models let me create the apps first so where my lecture and project so let me go there so lecture lecture comes first so so lecture will basically have the date that the lecture took place on or is going to take place on the title of the lecture the description and a link to the slide deck for the lecture and yeah between the descriptions and the slides that should have all of the information needed for a lecture okay so date title description and slides URL let me create that model Oh first I need the app for it yeah the more the more I think about it the more I like separating all these apps because I'm gonna have different relationships and URLs and stuff going on so it's just easier to separate them so let me do Python manage PI and then oh I didn't realize my face has been in the way when I've been creating apps this whole time all right there we go so I thought manage that PI start no no no no folder first so one second okay so first I'm going to make a new directory in the apps folder for my new app which will be lectures so lectures and now I will do Python manage pi and do oh yeah start app start app and then i'll do lectures and then apps slash lectures okay that's good and now let me go over here again to lectures and I'm gonna create a URLs that PI file okay good and now in my which file first models first so let me go and steal once again from my wait list so let me look at my wait list and go ahead and build from that it's so nice when you get a bunch of code or a bunch of projects already written and then you're like oh I remember I did that or even a live stream or something oh I did that before and you go back and you find out exactly what you did it's like your own personal Stack Overflow kind of okay I don't need a verbose name because lecture can be made plural with an S which is good okay so lecturer yeah I guess I'll have a timestamp I still want to date because I want because besides when it's created in the database I want to know exactly when the lecture is taking place so [Music] oh yeah so I guess it will be a date time technically because it'll be the time and the date for the lecture okay so anyways lecture so there will be a title and what else whether it be a date title description and slides URL so let's see so title description let me get rid of these date and slides URL all right so slides URL let me just say models dot char field max length equals let me stop that icon from bouncing one second my app wants to update right now okay that's my Notes app so I always have it open pretty much okay so slides URL max like that I'll just say 255 date so this will be models dot date field yeah I don't know if I need any options there and then description I want to change this so to a text field and then no max length in there then title will be a char field max likes 100 okay so I think that's it and then I get created at updated at timestamps on here so am I missing anything I don't think so let me go ahead and run the migration for that so python managed by make migrations okay and now Python managed dot PI and migrate okay now before I set up the admin and everything I do want to push this code to github so anyone following along can look at the code so I'm gonna do git status so lectures waitlist certificate changes okay and now I'll do get away I added new things so let me add those two new apps and now get commit dash M what should I call this I don't know added new apps okay so good and now let me get push and now all the code on github is updated do we need a lecture huh that's a good point so we have title description date slides hmm so should I add a field for like the name of a lecturer because we either have we ever have like a volunteer or a guest or somebody or one of our regular you know staff members lecturing so they may or may not be a user in the in this app so maybe for right now for MVP I can just have let's see oops lecturer name and make it models dot char field max length it's 100 yeah that's that's a good point um lecturer name and then I can also make this field let's see I could give it a default or make it nullable I'll give it a default so you don't really have to add the lecture oh wait then I'll have to say blank equals true write blank equals true oops okay that way you don't have to add the lecture and then just for linting let me see okay no flaky it's not complaining so I think that's good cool so now that I added this field though I have to make a new migration so let's see Python managed dot pi make migrations no changes oh let me put in the specific app because there should be a change here in lecture let's see migrations so actually there's nothing in migrations here for lectures why I thought there were migrations here oh is it because I haven't registered the app I think that's it because the password field is typed password so we officially define it in the serializer class maybe that's a message from a while ago I'm not sure because we moved on from users I'm not sure what that chat message is referring to let's see oh please check my comment maybe I missed a comment because no I only see the comment because the password field is typed password so we explicitly define it in the user user class one second okay so I do a waitlist oh I didn't add the lectures up here that's why you didn't catch the migration so oops let me just add the lecture zap is it called lectures yeah it's called lectures okay good so let me go to users real quick and you're saying because the password field is tight password so we explicitly define it in the serializer class okay you mean here in the serialize ER class I'm not sure what you mean by the comment you made I'm not understanding okay so let me just run the migrations again now that the app yeah so now it created the model okay so now I can do Python manage PI and migrate okay cool so oh yeah then I don't have an updated migration because I accidentally never ran it in the first place so now it created lectures with the lecturer name field cool alright so now let me move my face down I'm always worried about my face getting in the way okay and now let me add lectures to the admin interface so um let's see where am I putting okay let me copy from another let me just get a copy from certificates admin that's simple by the way code Jango are you a Django developer are you learning Django or you just are Django lover I'm guessing because your name is code Django okay so let me call this lecture admin and then import the lecture model for this admin setup so lecture and then here I'm gonna do lecture and then lecture admin okay and now in here I need to set my model fields so let's see I want to display title and I guess lecturer name and dates are important just in the regular table of course you can see all the information when you go into the lecture but those fields at least you should be able to see in the table list view so lecture name and then date okay I think those fields are good search fields you should be able to search by title and you should be able to filter by lecturer name really you cannot reorder the table by date so I'm not worried about that but you should be able to start typing in a lecturer name and see what lectures they've given so let me add a oh no that would be search that would be search yeah okay so um oops okay so lecture name here - okay lecture duration then you're just coming up with all kinds of new fields duration so do we need a duration so right now our lectures are only two hours long they're all two hours long so and that's another thing you know because we could have guest speakers at a different time outside of lectures so should we call it a lecture or should we call it meetings or something I don't know date generation yeah let me add a duration because let's see so lectures lectures plus are usually required for the students to attend or they're so you know they're supposed to attend though but we have like guest like guest lectures or guest speakers that come in like say if class is Monday and Wednesday students come at 6 p.m. every Monday Wednesday for lectures but then we have a guest coming on Sunday and they don't have to attend that one so how do we mark that as different and that again that would be a different time so we could do we could do it like an is required field and then here I guess we would put duration as well oops duration which would be time in hours so that would be an integer field duration so I would set the help text on duration I guess to advise people to enter in a number of hours so what do you think about these updates like is it a required lecture or basically is a part of the curriculum or is extra and then the duration in hours let me go ahead and start the duration so models dot integer field and then I can think I can set min equals 1 and max equals what would be the max 6 if we're doing a hackathon I don't know I'll just do a max of 10 nobody's gonna go longer than 10 hours okay so I don't even know if it's called min and Max but I'm assuming it is and so for duration and then we also want some special help text so let me see help text I think it's called help text let's see Django models help text you can just add help text yep it looks right okay so help text would be enter number of hours okay and now so now for is required this would be a models dot boolean field and then this would default to true so unless they set it as false meaning it's like it gets a guest lecture or something specific then it'll just be a regular lecture if it's required yeah okay so that looks better I think so should I run another migration yeah why don't I try it alright nobody said anything so I guess it's good let me do Python managed dot PI make migrations and that should make a new migration Oh got an unexpected keyword Minh type of lecture do I need a lecture type first let me look at Django integer field min and Max let's see oh do I have to add it as a validator let's see let me look min oh it keeps coming up with admin min value validator and Max value validator okay let's look at this okay so raises a value era with the code of min value if value is less than limit value and then okay so value so limit value and let's let me see so there's max value validator and min value validator if value is greater than limit value so limit value is a callable yes it is I have three foster kittens that are almost ready for adoption Wednesday I have to give them up for adoption so just enjoying them while they're here they're they're a weeks old now so they're big and wild and yeah basically um little troublesome child kitties but they're so cute though they're ginger kitties limit value so what is limit value then how do i set limit value if it's a callable so i guess i can create a function called limit value and where do i okay let me look at django limit value so i think if i just create a function on that class let's see defaults not exactly oh so I can set min value in Max value okay that's easier I don't need any other calculations so just min value and max value have you deployed the app you created in view with Django its back-end no I I'm still working on that one so that's the reasonable productivity one I did like three live streams in Django and then I've done to view live streams for that app so far or no I did like four danko and then to view front-end needs a lot of work in that app so it's not not ready for a deployment plus I was kind of getting used to next and getting that all set up but I'm hoping in the next few weeks I'll have a pretty good MVP set up for that app and then my curriculum app is about to be deployed and then for the other app just going down all my apps here regex breakfast I'm getting I hired a designer to redesign that app so I'm waiting for the designs to come back and then I'm going to do a live stream of me implementing designs for that app which is so much better than the live stream I did before where it was me and two other developers trying to design an app which went horribly we made it look awful thanks yeah I should be doing that later this week okay so what was I doing oh yeah I updated min and Max value here so what was that thing you suggested cigar Oh type of lecture sure do I need type of lecture type so that's the thing about type is I would think that type would be like an enum so it would be a choice field like you could choose between types so either I would need to make hard code a set of tuples to or a list of tuples to basically say that here are all the types or I need another database table for lecture types which i think is overkill right now so let's see I think I might add that to version 2 oh yeah I have my readme locally so let me update the readme here because I don't know how to handle that right now so let me add it down here so you have two new issues Wow okay I'll look at those in a second so set type of lecture ad type field to lecture model okay all right so I think this is OK for right now we added is required and we added duration so cigar Y cigar is this a pop culture reference because I probably won't get it yeah someone explain to me what that means all right so now let me try that migration to make the migration again nope Oh unexpected keyword min value so maybe that's from Python 2 or something else so I think I might need this limit value after all let me go back Django limit value how to limit the field so okay so that's a whole other thing so what if I so in validators I think I need to set a validator right so wait let me go - okay so integer field and then set a validator and then I can import validator so I could put validators in my maybe I should put a validator spy file in my utils because I'll probably be making more validator so let me let me see so Oh cigar oh I didn't realize that sorry that's ugh cigar I guess American people mispronounce it all the time then let me make a validators the validators dot pie file and utils and then here get text lazy yeah so let me import do some importing here let me just steal this my validators I don't need this translation so I have this validation function now let's see validate I want to validate I don't know should I just take out the validation do it later I kind of want to validate you know the min value and the max value for this let me see so if yeah and plus this is so custom it's not like I can reuse a validator for this unless what I do is pass in pass in I guess like a min value and a max value so no because the value is automatically passed in here so yeah I think I'm just gonna leave it without the validator and I hope that any sane person will not put a ridiculous number there so help text I'll just leave the help text that's fine okay I'll lose I'll leave this file intact wait so I'll leave the validators at PI file because I'm sure I'll need it later okay join your streams I like you a lot and I see you expert thank you I like me a lot too obviously that's my probably my favorite thing to do Django's my second favorite for streaming so far I actually just started so before I used to use flasks for everything like if I was making a Python API I would do it in flasks and then I did some Python services and stuff I didn't start using Django till last year because I saw it as like this Ruby on Rails type thing and I was I guess I don't know if scared is the right word but I was just thinking oh I don't want to get involved in that and learn all this all this boilerplate and then I started using it I started liking it because I got tired of setting all this stuff up by myself and Django does a lot of this for me okay so lectures now I need to be able to pull lectures into the front end so let me do what time is it Wow is it really - 36 min this stream just flew by how long three hours and 35 minutes that's unbelievable this is twice as long as my longest stream which is good it felt it felt fine to do hopefully it was interesting to watch okay so I have lectures now let me add URLs and views here so I'm going to copy it from certificates so except let me just update these two things again so what is it lectures or lecture you set and then okay and now I need to create the view set so let me go in here and in certificates or certificates love me okay so in certificates in views I'm going to copy this to over to here oops well alright so reporting sterilizers besets i need to import the correct model so i need to import the lecture model and then certificates a long word okay so lecture serializer and then down here one more time you need to do lecture view set by the way I'll be streaming view again Wednesday morning on this channel so it should be 10:00 a.m. Eastern Daylight Time just like normal for view and I'll maybe I'll make that stream longer maybe a couple hours of you to work on that app so let's see lecture the lecture model okay and then here I need this to be lecture and then a lot of this stuff is just you know the same stuff I set up in other apps so lecture serializer now the fields I need to change some of these fields though so let me go into the model and see so I have the title description thank you is your name Gerardo or Gerardo Miguel it's probably Gerardo I'm guessing okay so I D I do want ID let me put this on two lines so there all right so title description lecturer name I do want ID so I'm gonna start loops and start here with title description lecture name and then date duration slides URL and is required so date dur duration oops yeah okay and then slides URL and is required so for this one I really don't think I want the created at updated at on the front end you can see that from the admin interface but I don't see any reason to put it here thank you [Music] okay so yeah I think I don't need that anymore let me go - oops I'm not running the app help text got unexpected keyword okay so what was I doing now oh so I never actually ran the migrations did I you're trying to add an on nullable field duration to a lecture without a default okay so fortunately Janko gives me this these prompts that let me fix the fields already in the database so I'm going to provide a one time default so duration is an integer field so let me add - okay cool and now I can do Python managed by my great awesome so I have now it added the second migration so it's basically adding a field duration and adding the is required field to the lecture model okay cool and I ran that migration so it's updated in the database alright so let me run my server so Python managed dot pi run server okay and now yeah so this is already oh no it wasn't working because I never successfully ran anything all right so here's all my different fields for lectures I'm assuming they're all working because I was able to migrate fine so that's okay and now let me finish up my views so in my front end I think I have all of the fields that I want in my front end and I also have the URL setup so let me just I think the only thing left to do is do not in there in my config URLs I think here I'll need to set up lectures so lectures and then lectures yeah so I think that's good pending issues okay one second alright my server we started and now let me look here and I'm just going to test out the lectures URL cool awesome I can do crowd operations for lectures now okay so you're saying you added issues to my repo five issues now okay so wait list fields okay so I need to add this level level one or level two and then this is probably a document that's private so I shouldn't open it on a live stream so I'm not going to do that because it might have our students information so okay so I can add that to waitlist real quick so let me close this close this let me go into waitlist where's waitlist here this my waitlist app and then in models all the docs can be opened okay I wasn't sure so first name last name email notes so what I can do here is I think I can add let's add so I could add a full name function and then oh this would have self right and then I could return oh wait I don't do this on models do i or do I do it on I think it is on models isn't it and let me make an F string so I can do self dot first-name and am I doing this right someone correct me and self dot last name okay I think I can do that for full name and then for level I think I should add level here so I can do models dot integer field integer field and then I think I can add verbose name here and that would be class level I can change that later okay so I think this is correct let me see hi nobodies how are you it's good to see you in the stream again alright let me do a migration I know for our stream crazy right let me do a migration for I was hoping to get this done in one stream but it looks like I'm gonna need two for our streams to really get this working good awesome glad to hear it umm if the rest of you don't know nobody's has been in my streams since I basically started since I had like maybe 1,200 subscribers or something since I started live-streaming cool what what kind of keyboard are you buying I bought a new keyboard too but you can see plug it there are no key caps so I'm still learning what the keys are in programming all the keys as I want them which is gonna take me like a month oh cool brown brown or my favorite too I always get brown they seem a good mix between like a cherry red and tactile and stuff looks healthy you know I like healthy or the keyboard does the keyboard is super organ of yeah so I added this level's field and now I want to make a migration for it so I'm going to do Python managed dot PI make migrations so I need to provide ok so level is not nullable should wait should let me get out of that so should a level okay I'm gonna set a default for level actually because almost everybody signs up for level one first maybe that's gonna change in the future oh yeah you're fine but I'll set a default so that way it won't argue with me when I'm making this migration okay so it made a third migration in waitlist and it added that field level okay cool so now I can do Python and shot PI migrate to apply that to the database and very very good okay so currently oh I didn't see you added another comment with all this stuff currently we have Google Forms interest form I'd like to have them manually okay well I'm gonna have to look at this issue I was ready to close it but I'm gonna have to look at that issue later let me look at enrollment form real quick how much of this data should be moved to okay those are things I'm gonna have to look at after the stream this is a lot more everything everything when you're thinking about building something it seems like oh yeah I can get that done and then turns into like a hundred other things and I spent hours planning this app so I thought I had it all but it didn't I didn't so let me push my code what I've done so far so okay so it has all my new migrations utils all the files that all looks good okay so I'm gonna do a blanket ad period subscribe to the channel thank you thank you Python program right girl are you the first girl that commented in my livestream maybe I am glad you are watching okay so free code school API what did I just do oh yeah I just added so let me commit - M hi thank you Thank You Francis so let's say final commit from livestream on June 14th I know what today is because it's my birthday and I'm about to go eat a whole bunch of cupcakes and then maybe finish watching better call Saul because I am on the fourth season and that TV show is so good and I almost never watched TV shows so I but for some reason that one just hooked me in because it's very well made it also has to do with Breaking Bad so if you haven't seen Breaking Bad you have to watch that first but yeah so okay I push the code and now it should be live and working so let's see yup 38 seconds ago so all the code is live here which is in the description below I actually have to leave at 3:10 to go somewhere so any cupcakes oh you're on the 3rd season it's so good right that show is just so well made like everything the storytelling the acting everything ok yes so anyway thank you all for your birthday wishes I am going to be streaming again again yeah another long stream maybe next Sunday actually to finish up this app and I'll still be streaming Wednesday morning so if you want to see view J s you can see me streaming the VJ s application this Wednesday and I'm gonna post that stream later today so thanks so much for tuning in yeah join me on discord it's in the description also if you want to see the front end of this application Jared this guy in the chat the Jared will curt is going to be streaming this application right after this ends thank you thank you cigar thanks yeah so go watch Jared I'm gonna post it in the comments after the stream ends where his stream is so you can go follow him on Twitch not on YouTube he's on Twitch yeah thanks have a great night everyone take care send me virtual cupcakes and discord
Info
Channel: Faraday Academy
Views: 25,720
Rating: undefined out of 5
Keywords: django rest framework, python django api, how to build an api in python django, django, django tutorial
Id: sl43oS-36Ms
Channel Id: undefined
Length: 232min 36sec (13956 seconds)
Published: Sun Jun 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.