官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 沾化县| 景东| 扬州市| 吐鲁番市| 文成县| 鄂州市| 铅山县| 怀集县| 延川县| 金溪县| 莱西市| 佳木斯市| 漠河县| 贺兰县| 华蓥市| 营山县| 东至县| 佛学| 灵山县| 鲜城| 云梦县| 曲周县| 玉山县| 华坪县| 长汀县| 苗栗县| 宁明县| 合肥市| 天水市| 江西省| 岚皋县| 汽车| 新津县| 页游| 东至县| 莱阳市| 荆州市| 大余县| 五指山市| 合作市| 保德县|