Django's default management background -admin

 

New Project DjangoAdmin and application files

-web_django目录下创建项目文件
    -django-admin startproject DjangoAdmin 执行该命令创建工程,名为DjangoAdmin
-切换至DjangoAdmin目录下创建应用 
  -cd DjangoAdmin
  -方式一:python manage.py startapp App 
  -方式二:django-admin startapp App

pycharm Open Project Figure

 

 

 

 

Initialization modify the configuration file settings.py

-ALLOWED_HOSTS = ['*']   代表所有用户访问
-INSTALLED_APPS= [‘App’] 后面添加 App,注册应用app,项目文件中,新增应用后要及时再配置文件中进行注册

 

 

 

 

 

 Here to load the driver using sqlit3

  -database——+——Data Source ——SQLite

 

 

 

Performing a migration -

python manage.py migrate

 

 

 

After the migration is successful we refresh sqlit3 table information, see Figure

 

 

 

 

Configuring access content urls.py admin page file in the root directory as follows

 

 

 

 

 

 This time we start the service

python manage.py runserver

See http://127.0.0.1:8000/admin browser to access the following management-side pages

 

 

 

The default is no account, we have to create an account

    -创建admin用户密码 
        直接用命令行添加即可:python manage.py createsuperuser
        # python manage.py createsuperuser
        Username (leave blank to use 'root'): admin 账号
        Email address: [email protected] 邮箱
        Password:密码
        Password (again): 重新输入密码
        Superuser created successfully.
        

 

 

 


    -至此账号创建完成,登录admin账号查看成果
        -启动项目python manage.py runserver
        -浏览器访问 http://127.0.0.1:8000/admin/ 
        -提示登录窗中输入刚才创建的账号密码登录,登录成功后则看到管理员页面
    -同时在迁移的库中 auth_user表中会有一条记录,该记录为刚创建的用户信息

 

 

 

 

 

 

Here to make a change to make our visit a page in Chinese

 

Configuration file (settings.py)

LANGUAGE_CODE = 'zh-hans'

 

 Restart the service, we see the page into a Chinese page

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wfwt180801-/p/12044332.html