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.
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 manage.py migrate
To start a new app
python manage.py startapp myapp
Below we have the code from each necessary module.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
]
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('myapp/', include('myapp.urls'))
]
The urls.py module has to be created manually, under myapp directory.
from django.urls import path
from . import views
urlpatterns = [
path('', views.index)
]
from django.shortcuts import render
def index(request):
return render(request, '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
Finally, run the development server and visit localhost on port 8000.
python manage.py runserver
And in your favorite web browser open URL:
http://127.0.0.1:8000/myapp/