Skip to content

Instantly share code, notes, and snippets.

@cpinto
Created February 19, 2011 14:58
Show Gist options
  • Save cpinto/835103 to your computer and use it in GitHub Desktop.
Save cpinto/835103 to your computer and use it in GitHub Desktop.
a collection of django decorators
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