跟老齐学Python Django实战 1/n Second edition

virtualenv lqidjango
source bin/activate
pip3 install Django

  --> pass

django-admin startproject mysite

  --> fail

          

(lqidjango) cor@debian:~/lqidjango$ django-admin startproject mysite
bash: django-admin: command not found

  

python3 -m django startproject  mysite

  --> pass

#sudo apt-get install tree
(lqidjango) cor@debian:~/lqidjango/mysite$ tree
.
├── manage.py
└── mysite
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

1 directory, 5 files

  #

(lqidjango) cor@debian:~/lqidjango/mysite$ python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 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.

April 23, 2020 - 03:01:43
Django version 2.2.12, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Error: That port is already in use.
  #sudo apt-get install net-tools
cor@debian:~/webscrappython/Web_Scraping_with_Python/downloadAprial7th/wswp-code-9e6b82b47087/chapter08$ sudo apt-get install net-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  icedtea-netx icedtea-netx-common linux-image-4.9.0-8-amd64
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 248 kB of archives.
After this operation, 963 kB of additional disk space will be used.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/debian stretch/main amd64 net-tools amd64 1.60+git20161116.90da8a0-1 [248 kB]
Fetched 248 kB in 2s (92.8 kB/s)                             
Selecting previously unselected package net-tools.
(Reading database ... 272538 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20161116.90da8a0-1_amd64.deb ...
Unpacking net-tools (1.60+git20161116.90da8a0-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up net-tools (1.60+git20161116.90da8a0-1) ...
cor@debian:~/webscrappython/Web_Scraping_with_Python/downloadAprial7th/wswp-code-9e6b82b47087/chapter08$ sudo netstat -anutp|grep 8000
tcp6       0      0 :::8000                 :::*                    LISTEN      1804/docker-proxy

  

#

(lqidjango) cor@debian:~/lqidjango/mysite$ python3 manage.py runserver 7000
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 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.

April 23, 2020 - 03:37:15
Django version 2.2.12, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:7000/
Quit the server with CONTROL-C.

  

Start APP

python3 manage.py startapp blog
(lqidjango) cor@debian:~/lqidjango/mysite$ tree
.
├── db.sqlite3
├── manage.py
└── mysite
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-35.pyc
    │   ├── settings.cpython-35.pyc
    │   ├── urls.cpython-35.pyc
    │   └── wsgi.cpython-35.pyc
    ├── settings.py
    ├── urls.py
    └── wsgi.py

2 directories, 10 files
(lqidjango) cor@debian:~/lqidjango/mysite$ python3 manage.py startapp blog
(lqidjango) cor@debian:~/lqidjango/mysite$ tree
.
├── blog
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── db.sqlite3
├── manage.py
└── mysite
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-35.pyc
    │   ├── settings.cpython-35.pyc
    │   ├── urls.cpython-35.pyc
    │   └── wsgi.cpython-35.pyc
    ├── settings.py
    ├── urls.py
    └── wsgi.py

4 directories, 17 files

  

猜你喜欢

转载自www.cnblogs.com/winditsway/p/12759930.html