Django涔媋dmin

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django涔媋dmin相关的知识,希望对你有一定的参考价值。

鏍囩锛?/p>

 django amdin鏄痙jango鎻愪緵鐨勪竴涓悗鍙扮鐞嗛〉闈紝鏀圭鐞嗛〉闈㈡彁渚涘畬鍠勭殑html鍜宑ss锛屼娇寰椾綘鍦ㄩ€氳繃Model鍒涘缓瀹屾暟鎹簱琛ㄤ箣鍚庯紝

灏卞彲浠ュ鏁版嵁杩涜澧炲垹鏀规煡锛岃€屼娇鐢╠jango admin 鍒欓渶瑕佷互涓嬫楠わ細

銆€銆€1銆佸垱寤哄悗鍙扮鐞嗗憳

銆€銆€2銆侀厤缃畊rl

銆€銆€3銆佹敞鍐屽拰閰嶇疆django admin鍚庡彴绠$悊椤甸潰

澹逛付鍒涘缓鍚庡彴绠$悊鍛?/h2>
python manage.py createsuperuser銆€

 

璐颁付閰嶇疆鍚庡彴绠$悊url銆€銆€

url(r鈥榐admin/鈥? include(admin.site.urls)),

銆€

鍙佷付娉ㄥ唽鍜岄厤缃瓺jango admin 鍚庡彴绠$悊椤甸潰

1· 鍦╝dmin涓墽琛屽涓嬮厤缃?/span>

from django.contrib import admin
   
from app01 import  models
   
admin.site.register(models.UserType)
admin.site.register(models.UserInfo)
admin.site.register(models.UserGroup)
admin.site.register(models.Asset)

2·璁剧疆鏁版嵁琛ㄥ悕绉般€€銆€

class UserType(models.Model):
    name = models.CharField(max_length=50)
   
    class Meta:
        verbose_name = 鈥樼敤鎴风被鍨嬧€?
        verbose_name_plural = 鈥樼敤鎴风被鍨嬧€?

3·鎵撳紑琛ㄤ箣鍚?璁惧畾榛樿鏄剧ず,闇€瑕佹棭model涓綔濡備笅閰嶇疆

class UserType(models.Model):
    name = models.CharField(max_length=50)
   
    def __unicode__(self):
        return self.name

 

from django.contrib import admin
   
from app01 import  models
   
class UserInfoAdmin(admin.ModelAdmin):
    list_display = (鈥榰sername鈥? 鈥榩assword鈥? 鈥榚mail鈥?
   
   
admin.site.register(models.UserType)
admin.site.register(models.UserInfo,UserInfoAdmin)
admin.site.register(models.UserGroup)
admin.site.register(models.Asset)

4·涓烘暟鎹〃娣诲姞鎼滅储鍔熻兘

from django.contrib import admin
   
from app01 import  models
   
class UserInfoAdmin(admin.ModelAdmin):
    list_display = (鈥榰sername鈥? 鈥榩assword鈥? 鈥榚mail鈥?
    search_fields = (鈥榰sername鈥? 鈥榚mail鈥?
   
admin.site.register(models.UserType)
admin.site.register(models.UserInfo,UserInfoAdmin)
admin.site.register(models.UserGroup)
admin.site.register(models.Asset)

5·娣诲姞蹇€熻繃婊?/span>

from django.contrib import admin
   
from app01 import  models
   
class UserInfoAdmin(admin.ModelAdmin):
    list_display = (鈥榰sername鈥? 鈥榩assword鈥? 鈥榚mail鈥?
    search_fields = (鈥榰sername鈥? 鈥榚mail鈥?
    list_filter = (鈥榰sername鈥? 鈥榚mail鈥?
       
   
   
admin.site.register(models.UserType)
admin.site.register(models.UserInfo,UserInfoAdmin)
admin.site.register(models.UserGroup)
admin.site.register(models.Asset)

鏇村璇﹁锛歨ttp://www.cnblogs.com/wupeiqi/articles/5246483.html

銆€銆€銆€銆€銆€http://www.cnblogs.com/wupeiqi/articles/5237704.html

銆€銆€

以上是关于Django涔媋dmin的主要内容,如果未能解决你的问题,请参考以下文章

Linux涔媋nt瀹夎閮ㄧ讲

spring瀛︿範涔媋op(FactoryBean浠g悊)

如何在 Django Summernote 中显示编程片段的代码块?

Pytest绯诲垪锛?8锛? 瓒呯編娴嬭瘯鎶ュ憡鎻掍欢涔媋llure-pytest鐨勫熀纭€浣跨敤

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段