Python圈

Django基础1--安装及启动

2020-08-25  本文已影响0人  伊洛的小屋
1.Web框架
2.开始Django
Learn: python3 -m venv django
➜  Learn source django/bin/activate
(django) ➜  Learn
3.安装
pip3 install django
(django) ➜  Learn python3
Python 3.7.5 (default, Nov 29 2019, 14:32:46)
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
3.1
4.创建Django项目
(django) ➜  PycharmProjects django-admin startproject AutoPlatform
brew install tree
➜  ~ tree --help
usage: tree [-acdfghilnpqrstuvxACDFJQNSUX] [-H baseHREF] [-T title ]
    [-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version]
    [--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst]
    [--charset charset] [--filelimit[=]#] [--si] [--timefmt[=]<f>]
    [--sort[=]<name>] [--matchdirs] [--ignore-case] [--fromfile] [--]
    [<directory list>]
  ------- Listing options -------
  -a            All files are listed.
  -d            List directories only.
  -l            Follow symbolic links like directories.
  -f            Print the full path prefix for each file.
  -x            Stay on current filesystem only.
  -L level      Descend only level directories deep.
(django) ➜  AutoPlatform tree
.
├── AutoPlatform
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── manage.py

1 directory, 6 files
5.启动项目
(django) ➜  AutoPlatform python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 24, 2020 - 10:14:06
Django version 3.1, using settings 'AutoPlatform.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

NOTE: 用于开发的服务器在需要的情况下会对每一次的访问请求重新载入一遍 Python 代码。所以不需要为了让修改的代码生效而频繁的重新启动服务器。然而,一些动作,比如添加新文件,将不会触发自动重新加载,这时得自己手动重启服务器

欢迎下方【戳一下】【点赞】
Author:伊洛Yiluo
愿你享受每一天,Just Enjoy !

上一篇下一篇

猜你喜欢

热点阅读