zoukankan      html  css  js  c++  java
  • django开发Blog(2)

    (一)设置自动admin应用

    打开settings.py的INSTALL_APPS中的'django.contrib.auth'下面添加

    'django.contrib.auth',
    'django.contrib.admin',

    再次运行manage.py syncdb,生成django_admin_log

    (二)修改ulrs

    打开mysite\mysite\urls.py文件,改为

    from django.conf.urls import patterns, include, url

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

    urlpatterns = patterns('',
        # Examples:
        # url(r'^$', 'mysite.views.home', name='home'),
        # url(r'^mysite/', include('mysite.foo.urls')),

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

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

    (三)修改models

    打开mysite\blog\models.py,改为

    from django.db import models
    from django.contrib import admin

    class BlogPost(models.Model):
        title=models.CharField(max_length=150)
        body=models.TextField()
        timestamp=models.DateTimeField()

    admin.site.register(BlogPost)

    (四)运行测试

    运行服务器,输入manage runserver

    打开IE,输入http://127.0.0.1:8000/admin/

    出现登陆界面,输入用户名和密码即可登陆了

  • 相关阅读:
    只能输入数字的文本框
    Ajax
    Crtl+Enter提交留言
    onkeydown onkeyup键盘事件
    面向对象基础
    JS鼠标拖拽
    博客收藏
    不错的按钮
    如何在你的java程序中注册系统级热键
    开源GIS系统
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2722921.html
Copyright © 2011-2022 走看看