Creating a new django app and installing dependencies

Installed Apps
Installed Apps Tejas Sawant

This section is part of series Building REST API with Python & Django. Now we're going to create a new Django project and app for our student information API.

First We're gonna do this using the Django admin command line tool. Now we can use the Django admin command by django-admin startproject student_info .
What this does it passes arguments to start projects to say that we want to start a new project and it specifies the name of the project. So our project is going to be called the student_info and then the location that we want to create the project. So this last dot here this is optional. We are using . because we want to create it in the root of our project.


Now we have the Django project. We need to create an app within our project for our student information API. So a Django project can consist of one or more sub applications within the projects that you can use to separate different functionality within your projects.

So we're just going to create one API.

The student information API so we'll just create one app and we'll call the app as student_info_api. Now that we've tried our project we need to use the script instead of Django admin and then we'll type startapp student_info_api then hit enter. (python startapp student_info_api)


So this will create a new sub folder called student_info-api which has the,,, and the migrations folder. Basically this creates a new Django app within our project.

Now we need to enable our newly created student_info_api app in our Django project. The way that you enable an app in a project is you open up the student_info which is the root project
of our Django project and open up If you look at the this is the configuration file for our Django project. There's a block here called INSTALLED_APPS.


This is where you need to list all of the apps that you need to use for your project. So in our projects we can install apps by adding it to the installed apps list. So there's a few apps that we need to enable here in our installed apps.

So below the "django.contrib.staticfiles" line create a new line and type rest_framework. rest_framework is the djangorestframework that we installed earlier and this is the name of the app within the dependency djangorestframework package that we need to add to our project.

Below this we're going to add a another app from the djangorestframework and this is called the rest_framework.authtoken. This will allow us to use the authentication token functionality that with the djangorestframework.

Finally we're going to add our student_info_api app which we manually added to our project. So we're going to add a new line and write student_info_api. Make sure that you save your file and this is how we added apps to the INSTALLED_APPS of your Django project.

Installed apps

Finally we are going to test our project by using the django development server. So Django comes with a development server that we can use to test our changes in the browser as we make them to the project. The way you start the Django development web server is you type command python runserver. this is the default address for django project.

Running Server

Now that the servers running we can open up our browser and we can go to
That one that's the localhost address. You can see that the Django project place holder page has been displayed and it says The install worked successfully! Congratulations!.

Running Django App