Collector

安装

参考安装文章

?

创建项目project

转到你创建的目录,运行命令

django-admin.py startproject collector

生成下列文件

collector/

__init__.py

manage.py

settings.py

urls.py

?

Shell debug调试

python manage.py shell

>>> exit()

?

它背后是如何工作的: Django搜索DJANGO_SETTINGS_MODULE环境变量,它被设置在settings.py中。例如,假设collector在你的Python搜索路径中,那么DJANGO_SETTINGS_MODULE应该被设置为:‘collector.settings‘。

随着你越来越熟悉Django,你可能会偏向于废弃使用`` manage.py shell`` ,而是在你的配置文件.bash_profile中手动添加 DJANGO_SETTINGS_MODULE这个环境变量。

wsgi.py中

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lwc.settings")

创建应用application

In future, whenever you need to activate an application for your project, you can simply add its package name to the INSTALLED_APPS
variable. Depending on the application, you may also need to run python manage.py syncdb
to create the application‘s data models in the database. After that, the application will become available in your projec

?

$python manage.py startapp joins

就会在工程目录下创建一个joins目录:

joins/

? ?? __init__.py

? ?? models.py

? ?? tests.py

? ?? views.py

?

如果想要沿用default的app,需要把它加到INSTALLED_APPS

INSTALLED_APPS = (

joins,

?

创建数据库

在settings.py中配置数据库

DATABASES = {

‘default‘: {

‘ENGINE‘: ‘django.db.backends.mysql‘, # Add ‘postgresql_psycopg2‘, ‘mysql‘, ‘sqlite3‘ or ‘oracle‘.

‘NAME‘: ‘mydb‘, # Or path to database file if using sqlite3.

# The following settings are not used with sqlite3:

‘USER‘: ‘root‘,

‘PASSWORD‘: ‘123‘,

‘HOST‘: ‘‘, # Empty for localhost through domain sockets or ‘127.0.0.1‘ for localhost through TCP.

‘PORT‘: ‘‘, # Set to empty string for default.

}

}

执行下面命令同步数据库,它将会创建数据表和超级用户

$ python manage.py syncdb

?

调试模式

TEMPLATE_DEBUG = DEBUG = TRUE

?

启动服务器

可以用下面命令启动服务器,默认端口8000

python manage.py runserver

python manage.py runserver 8080

python manage.py runserver 0.0.0.0:8000

?

访问

http://127.0.0.1:8000/

虽然 django 自带的这个 web 服务器对于开发很方便,但是,千万不要在正式的应用布署环境中使用它。 在同一时间,该服务器只能可靠地处理一次单个请求,并且没有进行任何类型的安全审计。

?

第一个视图 – admin

setting.py

INSTALLED_APPS =
(

# Uncomment the next line to enable the admin:

‘django.contrib.admin‘,

# Uncomment the next line to enable admin documentation:

‘django.contrib.admindocs‘,

)

urls.py

# Uncomment the next two lines to enable the admin:

from django.contrib import admin

admin.autodiscover()

?

urlpatterns = patterns(‘‘,

url(r‘^admin/‘, include(admin.site.urls)),

==>

url(r‘^admin/*‘, include(admin.site.urls)),

#add this *, otherwise, /admin will go to below next urlPattern, * means repeating precious char (0~n)

url(r‘^(?P<ref_id>.*)$‘,
‘joins.views.share‘, name=‘share‘),

)

?


Symbol / Expression


Matched String


. (Dot)?


Any character.?


^ (Caret)?


Start of string.?


$?


End of string.?


*?


0 or more repetitions.?


+?


1 or more repetitions.?


??


0 or 1 repetitions.


|?


A | B means A or B.?


[a-z]?


Any lowercase character.?


\w?


Any alphanumeric character or _.?


\d?


Any digit. ?

?

http://docs.python.org/lib/module-re.html

?

时间: 2024-12-25 19:47:30

Collector的相关文章

Bone Collector

Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …The bone collector had a big bag with a volume of

hduoj 2602Bone Collector

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 40598    Accepted Submission(s): 16872 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bon

Bone Collector(杭电2602)(01背包)

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31604    Accepted Submission(s): 13005 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo

Java_garbage collector

摘自:http://blog.csdn.net/java2000_wl/article/details/8030172 HotSpot JVM垃圾收集器 上面有7中收集器,分为两块,上面为新生代收集器,下面是老年代收集器.如果两个收集器之间存在连线,就说明它们可以搭配使用. Serial(串行GC)收集器_Serial GC Serial收集器是一个新生代收集器,单线程执行,使用复制算法.它在进行垃圾收集时,必须暂停其他所有的工作线程(用户线程).是Jvm client模式下默认的新生代收集器.

hdu 4336 Card Collector

Card Collector http://acm.hdu.edu.cn/showproblem.php?pid=4336 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful cards in

HDU2639Bone Collector II[01背包第k优值]

Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4229    Accepted Submission(s): 2205 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par

HDU 2602 Bone Collector DP(01背包)

Bone Collector Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , c

hdu 2602 Bone Collector 01背包

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 50442    Accepted Submission(s): 21153 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bon

Bone Collector II(HDU 2639 DP)

Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3471    Accepted Submission(s): 1792 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par