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.

目录
相关文章
|
3月前
|
存储 Ubuntu 安全
在Ubuntu 16.04上安装Django并搭建开发环境的方法
在Ubuntu 16.04上安装Django并搭建开发环境的方法
21 0
|
SQL 缓存 Shell
Django系列:Django开发环境配置与第一个Django项目
Django开发环境配置与第一个Django项目的搭建。包括虚拟隔离环境,命令行工具的使用等。
153 0
|
Python
Python:Django开发环境与生产环境的配置
Python:Django开发环境与生产环境的配置
179 0
|
JavaScript 数据可视化 搜索推荐
Django+Vue开发生鲜电商平台之2.开发环境搭建
文章目录 一、PyCharm的安装和简单使用 二、MySQL和Navicat的安装和使用 三、Python的安装 四、虚拟环境的安装和配置 五、Vue开发环境搭建
Django+Vue开发生鲜电商平台之2.开发环境搭建
【Django | 开发】分离上线环境与开发环境(多settings配置)
【Django | 开发】分离上线环境与开发环境(多settings配置)
【Django | 开发】分离上线环境与开发环境(多settings配置)
|
Python
Python:Django开发环境与生产环境的配置
Python:Django开发环境与生产环境的配置
215 0
|
Shell Python
Django入门之开发环境搭建1.1
Django入门之开发环境搭建1.1
133 0
Django入门之开发环境搭建1.1
|
关系型数据库 MySQL Unix
使用 Docker 部署 Django + MySQL 8 开发环境
前一段时间重装了系统,然后我还没有备份,导致电脑里的开发环境全都没有了。 一想到又要装 Python 环境,还要装数据库,然后安装过程中还可能报一堆错就头疼。
1057 0
|
应用服务中间件 API 数据库
CentOS7 + Python3 + Django(rest_framework) + MariaDB + nginx + uwsgi 部署 API 开发环境
这是一个 Django 环境部署教程,也是一个我坑爹的 Django 环境部署记录
3727 0
|
Python Windows
如何在windows安装搭建django开发环境和所需要的软件
Python的虚拟环境的安装与配置(virtualenv) win+r 打开cmd pip install virtualenv 如下(): Microsoft Windows [版本 10.0.16299.492] (c) 2017 Microsoft Corporation。
1705 0