Django开发环境简单搭建

简介: Django开发环境搭建 thinkt@linux-pw37:~/.virtualenvs/v_python3.6/bin> ./pip install django thinkt@linux-pw37:~/.
Django开发环境搭建
thinkt@linux-pw37:~/.virtualenvs/v_python3.6/bin> ./pip install django
thinkt@linux-pw37:~/.virtualenvs/v_python3.6/bin> ./python -m django version
1.10.6
thinkt@linux-pw37:~/.virtualenvs/v_python3.6/bin> ./django-admin startproject mysite
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py runserver 8001
Performing system checks...

System check identified no issues (0 silenced).

You have 13 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 01, 2017 - 07:18:28
Django version 1.10.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8001/
Quit the server with CONTROL-C.
[01/Apr/2017 07:18:40] "GET / HTTP/1.1" 200 1767
Not Found: /favicon.ico
[01/Apr/2017 07:18:40] "GET /favicon.ico HTTP/1.1" 404 1936
Not Found: /favicon.ico
[01/Apr/2017 07:18:40] "GET /favicon.ico HTTP/1.1" 404 1936

thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py startapp polls
thinkt@linux-pw37:~/PycharmProjects/mysite/polls> ls
admin.py  apps.py  __init__.py  migrations  models.py  tests.py  views.py


thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py makemigrations polls
Migrations for 'polls':
  polls/migrations/0001_initial.py:
    - Create model Choice
    - Create model Question
    - Add field question to choice
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py sqlmigrate polls 0001
BEGIN;
--
-- Create model Choice
--
CREATE TABLE "polls_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "vates" integer NOT NULL);
--
-- Create model Question
--
CREATE TABLE "polls_question" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "question_text" varchar(200) NOT NULL, "pub_date" datetime NOT NULL);
--
-- Add field question to choice
--
ALTER TABLE "polls_choice" RENAME TO "polls_choice__old";
CREATE TABLE "polls_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "vates" integer NOT NULL, "question_id" integer NOT NULL REFERENCES "polls_question" ("id"));
INSERT INTO "polls_choice" ("id", "choice_text", "vates", "question_id") SELECT "id", "choice_text", "vates", NULL FROM "polls_choice__old";
DROP TABLE "polls_choice__old";
CREATE INDEX "polls_choice_7aa0f6ee" ON "polls_choice" ("question_id");
COMMIT;
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py check
System check identified no issues (0 silenced).
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying polls.0001_initial... OK
  Applying sessions.0001_initial... OK
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py makemigrations
Did you rename choice.vates to choice.votes (a IntegerField)? [y/N] y
Migrations for 'polls':
  polls/migrations/0002_auto_20170401_1758.py:
    - Rename field vates on choice to votes
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
  Applying polls.0002_auto_20170401_1758... OK
thinkt@linux-pw37:~/PycharmProjects/mysite> ~/.virtualenvs/v_python3.6/bin/python manage.py createsuperuser
Username (leave blank to use 'thinkt'):
Email address: talenhao@gmail.com
Password:
Password (again):
This password is too short. It must contain at least 8 characters.
Password:
Password (again):
This password is too common.
This password is entirely numeric.
Password:
Password (again):
Superuser created successfully.

目录
相关文章
|
7月前
|
SQL 缓存 Shell
Django系列:Django开发环境配置与第一个Django项目
Django开发环境配置与第一个Django项目的搭建。包括虚拟隔离环境,命令行工具的使用等。
97 0
|
Python
Python:Django开发环境与生产环境的配置
Python:Django开发环境与生产环境的配置
156 0
|
Python
Python:Django开发环境与生产环境的配置
Python:Django开发环境与生产环境的配置
178 0
【Django | 开发】分离上线环境与开发环境(多settings配置)
【Django | 开发】分离上线环境与开发环境(多settings配置)
【Django | 开发】分离上线环境与开发环境(多settings配置)
|
Shell Python
Django入门之开发环境搭建1.1
Django入门之开发环境搭建1.1
114 0
Django入门之开发环境搭建1.1
|
关系型数据库 MySQL Unix
使用 Docker 部署 Django + MySQL 8 开发环境
前一段时间重装了系统,然后我还没有备份,导致电脑里的开发环境全都没有了。 一想到又要装 Python 环境,还要装数据库,然后安装过程中还可能报一堆错就头疼。
833 0
|
Python Windows
如何在windows安装搭建django开发环境和所需要的软件
Python的虚拟环境的安装与配置(virtualenv) win+r 打开cmd pip install virtualenv 如下(): Microsoft Windows [版本 10.0.16299.492] (c) 2017 Microsoft Corporation。
1664 0
|
Python Windows 数据库管理
python +Django 搭建web开发环境初步,显示当前时间
1.python 的安装 网上很多关于django跟python 开发的资料,这块我正在实习准备用这个两个合起来搞一个基于web 的东西出来现在开始学习,写点东西记录一下心得。 开发环境是windows的,所以我们到python官网下载64位的windows操作系统的安装包: https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi 这个版本直接添加了系统的环境变量非常的方面(吐槽一下各种开发环境环境变量的配置)。
1706 0