Django Skeleton App

Django skeleton app is an app with only necessary and sufficient features to showcase the Django request response cycle. A simple Hello world text will be shown on the screen when the homepage is requested.

New Django Project & App

To get started with the skeleton project or the hello world project we must have python and Django installed. Here is a quick recap of all pre-requisites: /p>

To install Django LTS version 2.2:

pip install django==2.2                          

To verify django version:

django-admin --version                                

To start a new project:

django-admin startproject mysite
cd mysite
python migrate                                

To start a new app

python startapp myapp                                

Below we have the code from each necessary module.



mysite :

from django.contrib import admin
from django.urls import path, include
urlpatterns = [
        path('myapp/', include('myapp.urls'))

myapp :

The module has to be created manually, under myapp directory.

from django.urls import path
from . import views 
urlpatterns = [
        path('', views.index)

myapp :

from django.shortcuts import render    
def index(request):
    	return render(request, 'index.html', {})                         

mysite : templates : index.html

The templates directory has to be created manually, under myapp directory. Then index.html is also manually put under the templates directory.

Hello World                                

Django runserver

Finally, run the development server and visit localhost on port 8000.

python runserver                                

And in your favorite web browser open URL:                      

Django hello world project