#100DaysOfWeb in Python Transcripts
Chapter: Days 69-72: Django REST Framework
Lecture: Virtual env, install dependencies and quotes app

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Alright, let's get started. Let's get our Quotes app up and running to build it out with an API. In this day's lesson, I included a starter_code.zip
0:12 file so you can just download that. I'm already extracting it so just going to move this extracted zip file into Quotes new directory
0:32 inside Quotes near my Quotes app. So the first thing I'm going to do is to create the virtual environment and I have an alias for that
0:44 just to check I'm using Python 3.7. So I'm going to create the virtual environment and I'm not going to activate it yet cause I see
0:52 I have some environment variables that I have to set. So, let's copy this over. Get into the virtual environment. Go to the end.
1:06 And I'm going to set those 2 variables. SendGrid I'm not going to bother with and you're not going to use E-mail for this lesson.
1:15 And SECRET_KEY, you can just use an random text string and we're going to set the debug=True.
1:22 You'll want to do that at production, but we want to do that here to catch any errors while we're in development.
1:29 Then, I'm going to activate virtual environments which I have an alias for ae. If you're working in a Shell, it's very convenient
1:38 to have these aliases. Because typically, you'll be creating virtual environments and activating them all the time.
1:46 So at this point, we don't have the requirements installed. So look what we have and I already put in the Django REST Framework in there.
1:59 Registration from the last lesson so I can just pip install -r requirements.txt. Right, you have the dependency to install and now we can see
2:13 Django server response and as we've seen in previous lessons. We get a message that we have 20 Unapplied Migrations.
2:22 So Django looks into our source code, sees all of these migrations that are not in our database. So that's actually the first step to get
2:30 that database synced. And we'll just migrate and that syncs all of the migrations from our source folder into the database.
2:44 And we're just using SQLite. So this SQLite file base database has just been created. You can see that.
2:54 You're going to find and to open this with DB Browser. I can just load this in and here we have all the tables
3:11 these come with Django. And we have our own Quotes model that you'll remember from the previous lesson.
3:19 And that's actually the only customized model we have. And we're going to turn this into an API. Let's see if we can get to the server.
3:34 Go to my browser. localhost. And there you go. Last thing we need is the User. manage.py has another switch to create a Super User
3:50 and it's called Create Super User. So it's called pybites for now. And I have User and I can now login
4:09 to run the server again of course. Let's actually do this in a separate terminal. This will bite me again. Let's enable the virtual environment.
4:26 Let's have the server running second terminal. Just very convenient in developing. So I can login with the Super User and that's all done.
4:41 As you see there's no data in here. So in the next video, we're going to make a Django Admin command.
4:47 It's pretty cool like crumb jobs you can run with the manage.py utility we just used. And we're going to write one to process these CSV files
4:56 with Quotes and load them into the database to have some data to work with. So see you in the next video.


Talk Python's Mastodon Michael Kennedy's Mastodon