开发者社区> 天飞.h> 正文

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.

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
从后端到前端的简陋博客开发---by Django
7月12日,晴,陆陆续续的把Django入门教程看完了,了解到了一些前端知识,数据库,python的一些语法,比较顺利的开发了一个究极简陋的个人博客,实现了文章的发布与修改,也算是对Django有了初步的认识,激励我继续完成个人博客开发! 总结 1.熟悉settings.py文件的架构 2.掌握Model的运用 3.掌握urls的设置 4.编写Templates,通过浏览器呈现内容 5.熟悉Admin管理工具的运用 通过整一个流程下来,可以完成一个能上传文章,修改文章的简易博客,但之前一直是跟着教程打代码,好多细节都记不清了,甚至忘了。
1003 0
Python:Python多种集成开发环境(IDE,编译器)的简介、安装、入门、使用方法之详细攻略
Python:Python多种集成开发环境(IDE,编译器)的简介、安装、入门、使用方法之详细攻略
43 0
安卓开发环境的搭建(本文由本人根据网上的资料整理的成功版本)
本文的版权归文章写的人所有,本人负责整理,如有侵权,请联系我删除,谢谢! 最近公司要开始进行安卓系统的开发,所以我也要学习一下如何搭建安卓的开发环境了,这里我选择的路线是jdk+adt这种模式来搭建的,因为比较简单,所以就选择,接下来我们来看看如何搭建: 以下为该文件夹下文件的使用手册: 现在Android开发的环境搭建主要有以下几种方案: 1.jdk+eclipse+adt 2.Jdk+adt-bundle 3.Jdk+android studio jdk要去官网下载。
1147 0
第124天: Web 开发 Django 模板
第124天: Web 开发 Django 模板
25 0
ubuntu 10.10下搭建android开发环境 安装必要工作用软件
  进了新公司之后,工作环境有了很大的变化,以前都是在windows环境下进行程序开发,没怎么接触linux系统,新项目组中有6个同事,一水的ubuntu,木有办法,我也换成ubuntu吧。   曾经在学linux下c语言编程的时候,学过一个月的linux,熟悉了一些命令,稍微能在linux系统下完成一些日常的需求了,也搭建过android的开发环境,呵呵,时间长了,以前的东西又都忘了,由于那个时候也没把搭建环境的步骤进行记录,现在又抓瞎了,废了很大的劲,终于搭建完了,记录一下,为以后做好准备。
1259 0
第123天: Web 开发 Django 管理工具
第123天: Web 开发 Django 管理工具
43 0
django搭建个人博客遇到的常见问题
以下为本人在使用django搭建个人博客遇到的问题 1、django中的app项目中如果在url.py中使用 app_name = 'blog' 语句定义app名称,则在所有需要链接的地址中要这样写: ...
868 0
+关注
天飞.h
脚踏实地,仰望天空. https://talenhao.github.io/
260
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
JS零基础入门教程(上册)
立即下载
性能优化方法论
立即下载
手把手学习日志服务SLS,云启实验室实战指南
立即下载