Created
July 19, 2009 08:22
-
-
Save cwvh/149844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from foobar import models | |
class CommonSearchCriteria(admin.ModelAdmin): | |
search_fields = ('title',) | |
class AdvancedOptions(admin.ModelAdmin): | |
fieldsets = ( | |
('Advanced options', { | |
'classes': ('collapse',), | |
'fields': ('area',), | |
}), | |
) | |
class EllipseAdmin(CommonSearchCriteria, AdvancedOptions): | |
pass | |
admin.site.register(models.Ellipse, EllipsisAdmin) | |
admin.site.register(models.Rectangle) | |
""" | |
from django.db.models import base | |
m = models.__dict__ | |
for k in m.iterkeys(): | |
klass = m[k] | |
if type(klass) == type(base.Model): | |
admin.site.register(klass) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Shape(models.Model): | |
area = models.PositiveIntegerField(default=0) | |
class Ellipse(Shape): | |
radius = models.PositiveIntegerField(default=0) | |
class Rectangle(Shape): | |
width = models.PositiveIntegerField(default=0) | |
height = models.PositiveIntegerField(default=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment