#2 Writing your first Django app



Ram Bhardwajverified

@Sidharth

Founder and CEO at SidTube. Instagram: https://sidtu.be/r/instagram Discord: https://sidtu.be/r/MyDiscordServer

Writing your first Django app

Creating a project

If this is your first time using Django, then you need to take care of some initial setup. Namely, you will need to auto-generate some code that sets up a Django project - a collection of settings for the instance of Django, including database configuration, Django-specific options and application-specific settings.

Now, you have to cd in a directory where you want your project to be created...

And now run it in shell

$ django-admin startproject mysite

You could have used any name in place of mysite depending on what your project really is...

 

Let's look at what is made

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py

 

If you have this kinda files configuration then congratulations! You have done the first part of your app, you can run your app now!

So now let's run our app!

 

Now, Let's use the development server!

This will verify if the project works or not!

Go to terminal and write this command.

$ python manage.py runserver

If you see the following output on the command line then you are all good

Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

September 22, 2020 - 15:50:53
Django version 3.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

If this is your output then go to your browser and go to http://127.0.0.1:8000/

 

 

If this is what do you see on the page then congratulations your first app is created and you are ready to develop it!

 


Related Articles