Start a new Django Project

mkdir django-tutorials
cd django-tutorials
django-admin startproject mysite

The directory breakdown is as follows:

django-tutorials
|
|---mysite
|------mysite
|--------- __init__.py
|--------- settings.py
|--------- urls.py
|--------- wsgi.py
|------manage.py

Explanation

  • __init__.py Specifies to treat the folder as a package
  • settings.py Note: New applications have to be manually added under INSTALLED_APPS.
  • urls.py Controller

Check if project is working locally

python manage.py runserver

This will initiate the development server. Head over to a browser and access localhost:8000. You should see a welcome page.

Next, we will start to add apps to the site. In this case, we add webapp.

python manage.py startapp webapp

The directory breakdown is as follows:

django-tutorials
|
|---webapp
|--- migrations
|--- __init__.py
|--- admin.py
|--- apps.py
|--- models.py
|--- tests.py
|--- views.py

models.py specify the database information and metadata. views.py controls what your end-user sees and feels. urls.py controls what’s served based on URL patterns.

Leave a comment