Advertisement
black_eagle

admin.py

Aug 4th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from django.contrib import admin
  2. from django import forms
  3. from models import *
  4.  
  5. from filters import CategoryFilterSpec
  6. from django.contrib.admin.filterspecs import FilterSpec
  7.  
  8. def test_f(f):
  9.     return getattr(f, 'name')=='parent' and f.rel.to == Category
  10.  
  11. FilterSpec.filter_specs.insert(0, (test_f, CategoryFilterSpec))
  12.  
  13. class TagAdmin(admin.ModelAdmin):
  14. #    form    = TagAdminForm
  15.     list_display = ( 'slug', 'parent')
  16.     list_filter = ( 'parent', )
  17.  
  18.  
  19. admin.site.register(Category)
  20. admin.site.register(Tag, TagAdmin)
  21. admin.site.register(TestModel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement