zoukankan      html  css  js  c++  java
  • # Writing your first Django app, part 2

    创建admin用户

    D:desktop	odoListDjangomDjangodemoSite>python manage.py createsuperuser
    
    

    然后输入密码

    进入admin网址

        D:desktop	odoListDjangomDjangodemoSite>python manage.py runserver 8080
    

    改变字段顺序

    • fileds 改变字段的顺序

    • fieldset 给字段分组

    • classes 折叠字段

    • serch_fields 添加搜索框

    • list_display 需要显示的字段

    from django.contrib import admin
    from DemoAppPoll.models import Choice,Question
    
    class ChoiceInline(admin.TabularInline):
        model = Choice
        extra = 3
    
    class QuestionAdmin(admin.ModelAdmin):
        #fields=['pub_date','question_text']
        fieldsets=[
            (None,              {'fields':['question_text']}),
            ('Date infomation', {'fields':['pub_date'],'classes':['collapse']}),
            ]
        inlines = [ChoiceInline]
        list_display = ('question_text', 'pub_date', 'was_published_recently')
        list_filter = ['pub_date']
        search_fields = ['question_text']
        
    #admin.site.register(Question)
    admin.site.register(Question,QuestionAdmin)
    #admin.site.register(Choice)
    
    
  • 相关阅读:
    HTML颜色表
    grid
    DOM和BO
    注册表
    js 正则表达式
    python学习之路(一)
    python学习之路(三)
    python学习之路(二)
    自己编写的泛型集合类(其实是照着微软的List写的)
    客户端回调服务端无刷新事件
  • 原文地址:https://www.cnblogs.com/xilifeng/p/3961152.html
Copyright © 2011-2022 走看看