We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
# Create a directory for your virtual environment
# and Django project
mkdir tut1 cd tut1
# Setup Django virtual environment
pipenv install django==3.0
# Start the virtual environment
pipenv shell
# Create a project that will hold the apps
# Make sure you use a underscore and not a dash # in the project name django-admin startproject tut1 .
# Create a new app called pages
python manage.py startapp pages
# A Django project contains multiple apps that provide
# an individual piece of functionality. # A different app for each user authentication, # displaying database information, processing payments,...
# Project default files
# 1. admin : Config file for Django admin app # 2. apps : Config file for the app # 3. migrations : Tracks changes to the models file # 4. models : Define db models that Django translates # into db tables # 5. tests : Used to test the app # 6. views : Handles requests and responses with user
# You must add the app to the projects settings.py file
# Make sure it is added at the end INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'pages.apps.PagesConfig', <---- ADDED HERE ]
# Import views by looking in the directory for views.py
from .views import HomePageView
# Match for an empty request following the website
# name, reference the view named homePageView and # an optional URL pattern urlpatterns = [ path('', HomePageView, name='home') ]
# 3. Update the projects urls.py file to include our app
# This line says if they go to the website and don't # provide a directory they will be sent to our app from django.contrib import admin from django.urls import path, include