Friday, September 10, 2010

Playing with Django 0.96 - Class Meta & Class Admin

>>> for m in ModelName._meta.__dict__:
...       m
...
'unique_together'
'order_with_respect_to'
'installed'
'auto_field'
'has_auto_field'
'many_to_many'
'ordering'
'one_to_one_field'
'object_name'
'parents'
'db_tablespace'
'pk'
'verbose_name'
'get_latest_by'
'db_table'
'permissions'
'admin'
'fields'
'verbose_name_plural'
'app_label'
'module_name'
'aka'



>>> for m in ModelName._meta.admin.__dict__:
...       m
...
'list_select_related'
'save_as'
'save_on_top'
'list_per_page'
'ordering'
'fields'
'list_display'
'search_fields'
'js'
'date_hierarchy'
'list_filter'
'list_display_links'
'manager'


... Class Admin:
...       list_select_related = True
...       list_per_page = 20
...       manager = MyAdminManager()


Class MyAdminManager(models.Manager):
...       def get_query_set(self):
...             query_set = super(MyAdminManager, self).get_query_set().filter(id__gte=5)
...       return query_set

No comments: