Using the Django documentation and Mozilla tutorial, we will:
- Install django in a virtual envorionment
conda create python=3 <env_name>
orvirtualenv --p python3 <env_name>
- Create a project
- Create an app using
python manage.py startapp <app>
- Add our new app to settings.py
- Run migrations
- Create a superuser
- create subdirectories in the app directory for templates and static
- Test with runserver
I try to be consistent in the language I use. The
project directory
is the directory that was created withdjango-admin startproject <project_name>
. That directory containssettings.py
and other global assets. Anapplication directory
is created when you runstartapp
or add a third-party Django application (there are tons of them here). You can think of these as modules that we’ve imported to our central project.
Part II Create a simple webpage with Django:
- create a path for our index page in our app’s
urls.py
- create a view for our index page
path('', views.index, name='index'),
- create a
base.html
template - create an
index.html
file that extendsbase.html
- create a footer.html
- runserver!
Part III Add images and links using the Django template language
- Add images to the app’s static directory
- Add another path to urls.py.