Django + Github Copilot: AI Paired Programming

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

That’s wild it works so well. I’m 100% gonna use it. Probably a life saver for creating react components and setting up frontend in general as well

πŸ‘οΈŽ︎ 7 πŸ‘€οΈŽ︎ u/HornetBoring πŸ“…οΈŽ︎ Jul 02 2021 πŸ—«︎ replies

Looking forward to retiring in 10 years. Lol

πŸ‘οΈŽ︎ 5 πŸ‘€οΈŽ︎ u/goonbee πŸ“…οΈŽ︎ Jul 03 2021 πŸ—«︎ replies

Received preview access to Github Copilot and I wanted to give it a whirl in a fresh Django project.

πŸ‘οΈŽ︎ 4 πŸ‘€οΈŽ︎ u/tylersavery πŸ“…οΈŽ︎ Jul 02 2021 πŸ—«︎ replies

crazy

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/szozs πŸ“…οΈŽ︎ Jul 02 2021 πŸ—«︎ replies

Game changer

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/handflangwaxa πŸ“…οΈŽ︎ Jul 03 2021 πŸ—«︎ replies

Does it work with pycharm?

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/MagicWishMonkey πŸ“…οΈŽ︎ Jul 03 2021 πŸ—«︎ replies

Is it any better than Kite copilot?

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/shuki25 πŸ“…οΈŽ︎ Jul 15 2021 πŸ—«︎ replies

What the hell maaan, did you make an AI program to make your voice sound like Terrence Mckenna's ?!

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/illevens πŸ“…οΈŽ︎ Jul 31 2021 πŸ—«︎ replies
Captions
so i just got access this morning to github co-pilot which is a cool ai assisted paired programming experience i have not used it yet i don't know what to expect i've read a little bit about it um and uh i just thought it'd be fun to play around with django um with it and just see if it's helpful at all um so let's let's figure it out i've just set up a empty django project uh and then i created just a model called or a an app called core um so let's uh let's start defining some stuff so i'm gonna make a class called item which extends model stop models.model and what i want to do is kind of express what this is going to do so a model that has a name description and created uh and the date it was created as well as a status field sure and uh we'll just do three closing things let's see if this does anything there we go so i just wrote some stuff it is suggesting we have a name um description uh let's yeah let's how do you actually accept this i guess tab okay there we go so um this is awesome because okay this makes sense um all right all right uh and this is cool too because it used the date time field which is kind of exciting but it actually did the auto now add true uh which is how you can do it created that field um and yeah the naming makes sense like i would call it created at but i can live with with date created okay uh let's make another thing called uh purchase maybe and we're just making this up as we go um oops models.model and let's just okay oh this is just telling me it's just pulling in my other code but we don't want that so let's let's do it this way a model that represents purchases of items this could be interesting if it finds it a foreign key uh yeah oh my gosh um so it grabbed some stuff um so booster purchase of items with a purchase date and uh with it okay represents items with a purchase date and whether or not it was shipped i want to see if that will kind of do a boolean flag there so let's just let's just go with it okay look at this so we have the item it got the foreign key to it uh purchase date yup that makes sense shipped boolean field default false interesting okay i'm not sure where that came from but that's fine okay so we have a couple models i kind of want to make one more so let's see let's work within here if i did user equals models dot foreign key um i don't think i'll get anything exciting here we won't worry about that we won't worry about that this is already so cool okay um uh let's let's try this class item collection models.model and we'll just say a collection of multiple items connected uh well let's try just connected to a user let's see if it kind of like figures that out i doubt it will oh my god it did look at that so it made a user um with a foreign key to something we don't even have and it figured out okay auth.user which is the django user did the on delete this is insane okay um i swear i did not type any of this out before and like i didn't plan this to be like we're gonna do something cool um and it decided to use the username as as that that makes sense um amazing okay let's let's uh let's oh let's install black sure just let it let it do its thing um okay back here uh what i want to do now is let's let's run these migration or make migrations so python manage dot pi make migrations uh oh we have to add this app to our settings i did not even do that so i think we can go core dot apps dot core config i think is what it is um let's just make sure in apps core config yeah so that should allow it now it didn't auto and it didn't help with that but i think it's because it's just a string it's probably not even thinking it's code um so let's make migrations and let's migrate okay then um let's go to our admin uh i haven't done a fresh django project in a long time so i might uh um some you know i might not be very good at this uh class i think this is called okay here we go admin site um let's call this well first of all we need to go from dot models import and let's actually import specifically item item collection and purchase that seems weird i don't have any of those but uh cool it was it's trying it's trying and we'll call this item admin which is going to uh extend admin dot um this i don't remember let's see django admin register let's see how it's done these days admin.model admin oh look okay okay that was cool i figured out some stuff so it did a list display of the things except it pulled um i pulled some strange things here uh image and item type those are things we do not even have but uh i'll i'll allow it and just erase these two i think the other ones are fine oh there's not a price either um i mean there should be a price you would think let's actually add a price and see what it does uh price equals models actually let's see yeah that's good i think you like hang for a minute and figure stuff out yup decimal field uh six digits decimal places too sure and we will make our migrations uh one-off uh yeah we'll just write a one-off field of one zero dollar and we'll migrate that so now this is actually true um list filter item type that we again don't have that but it tried i'm still impressed okay cool so um item admin and i feel like you have to do one more thing admin.register and we have to put an item here okay so let's just see if we go to our localhost 8 000 slash admin uh oh i'm not running my server before we do that let's create a super user so we can actually log in okay we do have an issue core uh refers to item collection which is not callable yeah i figured uh i figured that would be the case uh oh it's trying to it's trying to do things for us this filter must be i don't know why oh maybe it was probably missing a trailing comma okay this filter refers to item collection um let's just let's just get rid of this it's trying real hard okay and we gotta run the server hey i don't know okay here we go so we have our items and we should be able to create an item test item oh status i didn't realize status was a boolean field that's funny uh thanks a.i let's put something a little a little more meaningful in there some lorem ipsum at least uh price 100 and sure we'll keep status checked because it just makes sense um all right so we have an item and if we register our other things let's just try admin register item collection sure class let's see if it starts to figure some stuff out for us it does it i don't know where this came from it was it's starting to figure out our next one i guess so let's let's just go with it and i'm just i'm never touched it i'm just going to use my tab key from now on that's basically my new coding process um obviously there's some issues with the ai to figure out these things uh let's make sure so uh item collection has a user and items yeah so none of this none of this makes sense um let's just put user for here and we can get rid of this stuff and then for a purchase we have an item the collection's not really a thing quantity is not a thing but i can see why it would think that kind of purchase date is though and let's put shipped in okay so we should have in here now in our two we have item collections um so let's create a collection it has test item and it's this one user purchases let's make a purchase uh test item purchased shipped ah let's say not shipped cool this is this is pretty fun uh let's take a view um okay again haven't haven't written django from scratch in a long time and mostly when i work with django i don't actually create views i do stuff with django rest framework um but we already kind of have some help here luckily i don't need to know anything let's just let's just do that now i know that we will need some urls uh so uh let's just do all of our urls here path and i can do include copilot.urls um that is not what we want because that i mean there isn't anything called copilot but i like where it's going with this uh let's say core.urls and we need a urls.pi in our core why won't the ai make this for me so we got our core and then probably just need those again url patterns equal let's see if oh yeah this is what i want i want it to just do it for me okay it's you know it's a good start it's a good start so we're just gonna do this and we're gonna go what we need from dot views import index and i think we just go i think you just go index again it's been a while include is not defined include is not defined i think that comes from here okay so let's go to just our root now and we get this template does not exist that makes sense so we never made that why don't the ai make it for us so i think you put a folder called templates and then a new folder called core and then a new file called index.html and uh let's just go hello world hey did it oh my gosh it's auto completing an exclamation mark for me this is amazing it's refreshed okay uh core index hl um where do you put the templates then or is it just in the root i thought it was like this there could be a setting we have to do um templates and i can't add you know app dearest to direct yeah it should be using the app dir okay let's just uh let's google this real quick uh so installed apps we have that templates quick google django templates in app folder so what do they do they have pages app then they have template yeah i swear that's what i did uh we have templates then the name of the module again like they do then index.html did i oh maybe is it just like that core slash i just don't remember how to do this and the ai is not helping um okay then do do do i just forgot how to do this i'm just going to put this here core slash index.html and refresh okay almost maybe uh directories well that's weird what is this slash thing face directory what is this slash what does that even do in python oh my gosh what what is this is it the same as doing like a plus no plus just broke it okay well the ai helped again there we go okay we have that it's not to say where i want it but um this is supposed to just be really fast okay uh so let's close a bunch of things and open up our view so in our index uh let's actually get some things um let's just try doing something like well i will i'll help it out a bit just by going from dot models import item and i'm just gonna do a list of all items oh my goodness are we seeing this what the okay um then in theory if i go to my index.html let's see what you know i know where this is like django but this is part of django right so let's make a can i just let's write a comment in html a table that lists all items come on i guess they haven't got uh let's just start maybe doing stuff and maybe it will catch up well it got i knew i wanted to write a tr tag that's very good um let's put a uh okay here we go here we go i'm getting something we are getting something for item in items that's exactly what i want and let's see if it and four yeah um now can i uh maybe maybe if i use um how do you do a comment um in in jinja uh well if item.type is equal to book this is crazy i know we don't have that but um so we'll have a tr there we go that's what i want i want some kind of thing like that item.description amazing let's see if anything else it's like i have no other no other ideas for you just let's close that off but let's uh let's find out uh template does not exist at index uh oh ah something got messed up core slash index we lost that in the ai thing there we go we have a table uh what amazing okay um sweet uh well yeah okay so we got a little bit of views happening we definitely had some stuff with models even did a little bit of help with our html uh what else could we do here let's make a new thing called um is it reading my mind i was just about to write the word detail okay yeah um this is exactly what i want um what the hell um [Music] this is stupid i'm out of a job might have a job i don't know i don't know what i'm gonna do well no okay um well let's make that file detail.html because that's what it says to make it and and then yeah we just need to make a url i guess for this in our urls and path i want uh i forget i forget actually how to do this uh django url params and uh yeah wait i'm searching for the right thing okay well maybe there'll be some here we go yeah so it's just comma id and we want to import uh detail here so detail and i think we need a four yeah we want to have a forward slash here and i think i feel like this is what's up before his last two but whatever seems to be working okay so let's uh let's first of all just try to manually go to one i'm assuming slash one is an id looks like it worked um let's do an h1 and see if we go like this if it starts to figure some stuff out for us doesn't look like it that's okay that's okay cool back to our list view and let's just add one more td called and let's uh yeah okay cool um item.url uh now that won't work but um view this needs to be slash uh just slash the id item.id there we go test item wow wow and then obviously over here we can put let's see if now that it kind of has some little bit of context if it can auto complete our description thing item dot no that doesn't look like it that's okay that's okay we still like you there we go we have our description cool um [Music] how far do we want to take this okay we're gonna take this just a tiny bit further um we're going to create a new app python all right sorry django admin uh start app i'm gonna call it api and we're also gonna pip install django rest framework jokes okay so we have our api um i pulled up the api docs here because uh i just want to remember how to do this stuff so inside api um we need to do um let's just do it and i think we can yeah we'll start with the views and we'll come back to the serializers all right let's make the serializer first new file called serializers.pi and let's make sure in our settings file that we have installed core dot are not core api.apps.api config okay uh so in here let's make our serializer so we need to import our models so from core i'm just waiting i'm only waiting to see if it does stuff for me it seems to uh yeah i think when you have something sort of already pending in nvs code it doesn't go but import star would technically work here but i want to actually import what do we have item and uh and purchase i won't worry about the collection right now hey oh yeah we'll import that sure why not um it did tell us to and then from django is it just rest framework from rest framework import serializers that's exactly what we want i don't know if it is just guessing or if it knew you know we're probably trying to make a serializer here i'm guessing the latter here we go okay class item serializer sweet i'm just gonna push enter okay class meta yeah this looks i mean this is close uh again it's ticking obviously there's you know it's not necessarily using it seems like it's a hybrid between using you know our current code base as well as other projects in github um so i think we have a price you have a description we don't have an image but we do have the create we don't have these either it's called it's called something else let's just let's just keep it simple so we'll have our fields um and then let's make our it wants us it really wants us to type that out doesn't it let's take another one called class purchase i'm just gonna hang out yeah um cool now um will it because the item is a uh remember how to do this item equals item serializer yup um and i believe you pass in um i am i don't know yeah i think that is correct actually okay so serializer let's go to our views of this and uh we definitely need to import those same models from core dot models import installing an import star but we're gonna import purchase and um item okay um and we want to go from dot serializers import purchase serializer item serializer very good very good and let's make a class called i was trying to think of what to call it and look at us now there we go that's basically what we need and then let's make a class called uh item view set yup that's like crazy um sure okay and i think the last thing left is we do need a urls.pi here and we'll go to our other urls our project urls and just make one called api and we want to import api.urls then i'm just going to grab all this stuff uh so we'll keep this we'll have item here and this will be uh let's also go so from dot views import item view set and purchase view set and i believe it's itemviewset.as view i think and then um we'll just do another one for purchase purchase view set dot as view okay and this may or may not work okay view sets is not defined what it where's that coming from because we didn't import it why didn't the ai import for us um because i just didn't write the word from just gotta write the word from okay um [Music] i definitely did something here wrong uh yeah there's our apf that's for that uh how do you how do you do this again oh we do need to install rest framework uh settings let's put it there and what else do we miss i think there's still something with the urls that i'm not doing properly um include router. okay so they they're doing it this way sure i've never done it this way but i will do it this way no problem um let's go to our urls and from rest framework import routers and we want to register not users but item um and purchase and this will just be item view set and purchase view set then i guess the way the url patterns work uh let's let's just try it path tell me stuff okay redwater.urls that's what we want almost almost we have to wrap it in include but it did pretty good and then uh let's see if we can start doing the path um api off let's just see if it kind of figures that stuff for us here come on come on co-pilot oh yeah that's exactly what we want oh my god okay um let's see let's just restart this include not defined of course where does that come just like before okay let's go back here and so let's go to slash api there we go api root to do it's telling us stuff and then we'll go slash item method not found um [Music] items uh okay we missed something let's let's actually make these plural because that is what the tutorial said uh what did they miss what did we miss here um oh it's probably just the we need a slash at the end nope um api i think it's wait it's weird because this one well let's uh yeah let's go back here okay so wait that is working what oh i'm missing uh there needs to be a slash on um where's our core urls there should be a slash here okay so now if we go refresh api items there we go we have an api um and slash purchases field name user is not valid for purchase that makes sense we don't have a user serializer so rather than making that let's just omit it serializers user maybe there's a built-in there might be a built-in user serializer i mean we could just yeah we could just use the primary key relatable field that was that was pretty sweet it just did that okay there's definitely an issue um the serializer field might be naming correctly primary key user.objects.all it is importing user um and are we importing serializers yeah okay i'm not i'm not sure i'm not sure what's happening there but let's comment you out come on you out all right well it's working and in theory if i uh go to purchase slash one we actually get that specific item back amazing okay um that's good for now uh yeah i just kind of wanted to do a really quick 30 minute look into uh how impressive and cool this is uh definitely check it out in so far um it obviously works in in python i know that and and django too so uh yeah check it out uh if you um want to get access to it i just signed up uh by going here and doing sign up and then basically um you'll get hopefully you'll just get an invite you'll get access to uh to it and then you just have to install an extension technically you can install the extension now but it does authorize you'd have to like authenticate through github to actually start using it so you can't really sneak around that thanks for watching
Info
Channel: Tyler Codes
Views: 10,897
Rating: undefined out of 5
Keywords:
Id: 3JweDks6vUA
Channel Id: undefined
Length: 31min 48sec (1908 seconds)
Published: Fri Jul 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.