亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪(fǎng)問(wèn)板塊 發(fā)新帖
查看: 3323 | 回復(fù): 0
打印 上一主題 下一主題

Django 學(xué)習(xí)記錄(一) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2011-12-20 09:48 |只看該作者 |倒序?yàn)g覽
1,在ubuntu環(huán)境下安裝django:

sudo apt-get install python-django

 

2,安裝python mysql相關(guān)的支持庫(kù)文件:

sudo apt-get install mysql-server python-mysqldb

 

3,開(kāi)始創(chuàng)建一個(gè)django的project:

django-admin startproject mysite

會(huì)在mysql目錄下面自動(dòng)生成四個(gè)文件:

mysite/
    __init__.py
    manage.py
    settings.py
    urls.py

4,首先配置settings.py中數(shù)據(jù)庫(kù)相關(guān)的設(shè)置:(這里使用mysql為列)

修改數(shù)據(jù)庫(kù)配置:

DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'dbname'             # Or path to database file if using sqlite3.
DATABASE_USER = 'dbuser'             # Not used with sqlite3.
DATABASE_PASSWORD = 'password'         # Not used with sqlite3.
DATABASE_HOST = '127.0.0.1'             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '3306'             # Set to empty string for default. Not used with sqlite3.

修改時(shí)區(qū):

TIME_ZONE = 'Asia/Shanghai'

修改系統(tǒng)顯示語(yǔ)言:

LANGUAGE_CODE = 'zh-cn'

在INSTALLED_APPS加入后臺(tái)相關(guān)內(nèi)容:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.admindocs',
)

5、同步數(shù)據(jù)庫(kù)信息、并添加管理后臺(tái)用戶(hù):

ubuntu:~/mysite$ python manage.py syncdb           
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'zhaozhigang'): admin
E-mail address: admin@3cc.com.cn
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model

6、設(shè)置urls.py開(kāi)通后臺(tái)管理訪(fǎng)問(wèn)設(shè)置:

ubuntu:~/mysite$ cat urls.py
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from mysite.hello import hello
from mysite.currtime import *
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('mysite.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

7,啟動(dòng)django的web服務(wù):

ubuntu:~/mysite$ python manage.py runserver 0.0.0.0:8000
Validating models...
0 errors found

Django version 1.1.1, using settings 'mysite.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

[14/Jan/2011 23:23:28] "GET /admin/ HTTP/1.1" 200 1907
[14/Jan/2011 23:24:01] "GET /admin/doc/ HTTP/1.1" 200 2388

8、http://127.0.0.1/admin 即可登陸管理后臺(tái)。

管理后臺(tái)顯示中文:

在setting.py中的MIDDLEWARE_CLASSES添加:

 'django.middleware.locale.LocaleMiddleware',

 

9、登陸管理后臺(tái)提示:

You don't have permission to edit anything.

你無(wú)權(quán)修改任何東西。

的解決辦法:在url.py總?cè)∠鸻dmin.autodiscover()前面的注釋即可!

admin.autodiscover()
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP