>> Hi there. I'm Christopher Harrison.
I'm a Senior Cloud Advocate inside of Microsoft Cloud and AI.
What I want to do in
this video and across the next couple as well,
is begin to take a look at Django.
Now, for those of you who aren't familiar,
Django is a Python-based web framework.
It's built for what are sometimes
known as CRUD or data-driven applications,
where CRUD stands for create,
retrieve, update, and delete.
Or in other words,
it's built for applications where what I'm looking to
do is to create front end for a back-end database.
That what I want to do is put out information about my products,
allow people to buy them.
I want to create a line of business application.
I want to create a content management system, etc.
That basically, I've got information back here in a database,
I want a web front end.
Django is a great tool for that.
What makes Django really special is the fact that it's
aid to use the Python terminology, a batteries-included framework.
Meaning that there is a lot of really neat features and
functionality that Django has built-in that
can actually save you a lot of time and a lot of energy.
Because when you think about
those style of data-driven applications,
there's oftentimes a lot of duplicated code,
a lot of things I'm having to do
over and over and over again that I'm constantly
having to create forums
and constantly having to write a little bit of code to
go get one item out of a database by the Primary Key, etc.
Fortunately, Django knows all of this,
and it's got a lot of great tooling
that can automatically handle that for me,
with me being able to write very little and sometimes
even basically no code at all.
With that, let's turn our attention to the first step really,
with any framework or any library,
and that is installing it.
I've got Visual Studio Code open here.
I've got an empty folder that I've
creatively titled Django videos,
and I want to do the installation.
Now, I'm going to put this inside of our virtual environment,
which you should always do.
I'll do this by saying Python 3.8.
I'll use version 3.8 here.
I'm using WSL analytics.
If you're using Windows,
the syntax will change just slightly,
but the concepts are still the same.
I'm going to run a module here,
the virtual environment module,
and I'm going to put my virtual environment
into a folder called venv.
You can call that whatever it is that you want.
A lot of people like to put
a dot in front of it to make it hidden,
or maybe just env or whatever it is.
I like venv. That's just me.
That's what I'm going to call that.
If you're not already familiar with virtual environments,
what this will do is it will actually
create a new folder where all of
my libraries and my binaries and everything
else are going to be stored to run my application.
Now, the key file that I want to create here
is going to be a little file called requirements.txt.
Inside of requirements.txt, I'm going to list Django,
Django, there we go, as a requirement.
Now, the reason that you want to put this into a requirements.txt
file is so that way when somebody clones your project,
maybe you've put this out onto GitHub,
or when you go to deploy it,
that the deployment process or the person that CRUD
your code will then know what frameworks,
what libraries are needed to be installed.
Really almost any deployment mechanism
that you might be using is going to
look for a requirements.txt
file and install whatever it is that's there.
It's a best practice,
it's a common convention,
and it's one that you should follow along with.
I'm going to list Django inside of there.
Now before I install it,
I did skip one little step here.
Let's make sure I don't forget
to activate the virtual environment.
I'll do that by saying source venv bin activate.
There we go. Make sure that we do that.
Now, let's go ahead and pip
install-r and then that requirements.txt file.
Now, it will install Django for me.
As I highlighted that little venv folder,
if I go into lib and I go looking around,
you're going to notice that there is Django right there.
We've now installed Django,
we set up our virtual environment,
we set up our requirements.txt file.
The next thing is to then start to, well,
creating everything that we're going to need for Django,
which is what we'll do in the next video.
[MUSIC]