Starting your social website project

Open the terminal, and use the following commands to create a virtual environment for your project and activate it:

mkdir env
virtualenv env/bookmarks
source env/bookmarks/bin/activate

The shell prompt will display your active virtual environment, as follows:

(bookmarks)laptop:~ zenx$

Install Django in your virtual environment with the following command:

pip install Django==2.0.5

Run the following command to create a new project:

django-admin startproject bookmarks

After creating the initial project structure, use the following commands to get into your project directory and create a new application named account:

cd bookmarks/
django-admin startapp account

Remember that you should activate the new application in your project by adding it to the INSTALLED_APPS setting in the settings.py file. Place it in the INSTALLED_APPS list before any of the other installed apps:

INSTALLED_APPS = [
'account.apps.AccountConfig',
# ...
]

We will define Django authentication templates later on. By placing our app first in the INSTALLED_APPS setting, we  ensure that our authentication templates will be used by default instead of any other authentication templates contained in other apps. Django looks for templates by order of app appearance in the INSTALLED_APPS setting.

Run the next command to sync the database with the models of the default applications included in the INSTALLED_APPS setting:

python manage.py migrate

You will see that all initial Django database migrations get applied. We will build an authentication system into our project using the Django authentication framework.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset