Django Admin Attributes - 1
Bu eğitimimizde Django admin attributes konusunu işledik.
from django.contrib import admin
from .models import Article,Category,Kullanici
class ArticleInline(admin.TabularInline):
model = Article
extra = 0
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
list_display = ("title","created_date","modified_date")
list_display_links = ("title",)
list_filter = ("created_date",)
list_per_page = 100
search_fields = ("author",)
search_help_text = "title alanına göre arama işlemi yapabilrisiniz"
save_on_top = True
readonly_fields = ("created_date","modified_date")
autocomplete_fields = ("author",)
ordering = ("created_date",)
def update_title(self,request,queryset):
queryset.update(title="aaaaaaaaaaaaaaaaaa")
actions = [update_title]
admin.site.register(Category)
@admin.register(Kullanici)
class KullaniciAdmin(admin.ModelAdmin):
search_fields = ("first_name",)
inlines = [ArticleInline]
Yorumlar
Henüz Hiç Yorum Yapılmamış