看完了Writing your first Django app, part 1,我的笔记(1)
2006-07-27 17:45
387 查看
谈一下感想
大部分时间花在配置环境上了,很痛苦、很麻烦,自己的linux水平太低了,许多东西都不太理解,仅仅是照着文档来安装,一旦出了一点问题,连变通的办法都没有 。
笔记
Writing your first Django app, part 1
-----------------------------------------
Creating a project
django-admin.py startproject mysite
The development server
Database setup
这部分真够麻烦,我安装mysql遇到了好多问题呢,Linux要好好学习才行。问题详见blog。
运行python manage.py syncdb
后,我建立了一个超级帐户,用户名develop,密码develop
以下是自动建立的表
mysql> show tables;
+----------------------------+
| Tables_in_mysite |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_message |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| django_content_type |
| django_session |
| django_site |
+----------------------------+
10 rows in set (0.01 sec)
以上的工作完成后,所有的“project”环境就已经搭建完成
Creating models
"project"与"app"的关系
Projects vs. apps
What's the difference between a project and an app? An app is a Web
application that does something -- e.g., a weblog system, a database of
public records or a simple poll app. A project is a collection of
configuration and apps for a particular Web site. A project can contain
multiple apps. An app can be in multiple projects.
To create your app, make sure you're in the mysite directory and type
this command:
python manage.py startapp polls
That'll create a directory polls, which is laid out like this:
polls/
__init__.py
models.py
views.py
This directory structure will house the poll application.
In our simple poll app, we'll create two models: polls and choices
Activating models
That small bit of model code gives Django a lot of information. With it,
Django is able to:
Create a database schema (CREATE TABLE statements) for this app.
Create a Python database-access API for accessing Poll and Choice
objects
Playing with the API
python manage.py shell
We're using this instead of simply typing "python", because manage.py sets up the project's environment for you.
大部分时间花在配置环境上了,很痛苦、很麻烦,自己的linux水平太低了,许多东西都不太理解,仅仅是照着文档来安装,一旦出了一点问题,连变通的办法都没有 。
笔记
Writing your first Django app, part 1
-----------------------------------------
Creating a project
django-admin.py startproject mysite
The development server
Database setup
这部分真够麻烦,我安装mysql遇到了好多问题呢,Linux要好好学习才行。问题详见blog。
运行python manage.py syncdb
后,我建立了一个超级帐户,用户名develop,密码develop
以下是自动建立的表
mysql> show tables;
+----------------------------+
| Tables_in_mysite |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_message |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| django_content_type |
| django_session |
| django_site |
+----------------------------+
10 rows in set (0.01 sec)
以上的工作完成后,所有的“project”环境就已经搭建完成
Creating models
"project"与"app"的关系
Projects vs. apps
What's the difference between a project and an app? An app is a Web
application that does something -- e.g., a weblog system, a database of
public records or a simple poll app. A project is a collection of
configuration and apps for a particular Web site. A project can contain
multiple apps. An app can be in multiple projects.
To create your app, make sure you're in the mysite directory and type
this command:
python manage.py startapp polls
That'll create a directory polls, which is laid out like this:
polls/
__init__.py
models.py
views.py
This directory structure will house the poll application.
In our simple poll app, we'll create two models: polls and choices
Activating models
That small bit of model code gives Django a lot of information. With it,
Django is able to:
Create a database schema (CREATE TABLE statements) for this app.
Create a Python database-access API for accessing Poll and Choice
objects
Playing with the API
python manage.py shell
We're using this instead of simply typing "python", because manage.py sets up the project's environment for you.
相关文章推荐
- Writing your first Django app, part 1
- # Writing your first Django app--part 3 about view
- Writing your first Django app, part 2
- [笔记]Writing your first Django app
- # Writing your-first Django-app-part 4-simple-form
- Writing your first Django app, part 1(转)
- # Writing your-first Django-app-part 5 -test
- 搭建自己的Django应用(3)Writing your first Django app, part 3
- Writing your first Django app, part 2---IE的问题吗?费解
- 搭建自己的Django应用(2)Writing your first Django app, part 2
- [翻译]Django1.11 Writing your first Django app, part 1
- Writing your first Django app, part 1
- Writing your first Django app, part 1
- 你好,Django之Writing your first Django app, part 1(记录文档)
- 搭建自己的Django应用(1)Writing your first Django app, part 1
- Writing your first Django app, part 1
- # Writing your first Django app, part 2
- Writing your first Django app--Django 第一步
- Python Django的使用:Writing your first Django app--实践
- Django 官方文档write your first Django app --4