Created
February 19, 2011 14:58
-
-
Save cpinto/835103 to your computer and use it in GitHub Desktop.
a collection of django decorators
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 | |
def AutoManaged(clazz): | |
""" The AutoManaged decorator can be used on model classes which you want to have available | |
on the administration site with the stock admin forms. | |
Example usage: | |
@AutoManaged | |
class MyModel(models.Model): | |
someText = models.TextField(maxlength=100) | |
""" | |
try: | |
admin.site.register(clazz) | |
except admin.sites.AlreadyRegistered: | |
pass | |
return clazz | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment