文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Activating the Admin Interface

Activating the Admin Interface

时间:2010-05-05  来源:angelia_liu

Activating the Admin Interface

1. Add 'django.contrib.admin' to the INSTALLED_APPS setting.

2. Make sure INSTALLED_APPS contains 'django.contrib.auth', 'django.contrib.contenttypes' and 'django.contrib.sessions'. The Django admin site requires these three packages.

3. Make sure MIDDLEWARE_CLASSES contains 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware' and 'django.contrib.auth.middleware.AuthenticationMiddleware'.

4. Second, run python manage.py syncdb.
   This step will install the extra database tables that the admin interface uses. The first time you run syncdb with 'django.contrib.auth' in INSTALLED_APPS, you’ll be asked about creating a superuser. If you don’t do this, you’ll need to run python manage.py createsuperuser separately to create an admin user account; otherwise, you won’t be able to log in to the admin site.

5. add the admin site to your URLconf (in urls.py, remember).
   By default, the urls.py generated by django-admin.py startproject contains commented-out code for the Django admin, and all you have to do is uncomment it. For the record, here are the bits you need to make sure are in there:

# Include these import statements...
from django.contrib import admin
admin.autodiscover()

# And include this URLpattern...
urlpatterns = patterns('',
    # ...
    (r'^admin/', include(admin.site.urls)),
    # ...
)


With that bit of configuration out of the way, now you can see the Django admin site in action. Just run the development server (python manage.py runserver, as in previous chapters) and visit http://127.0.0.1:8000/admin/ in your Web browser.
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载