Login

Snippets by ncw

Snippet List

Type less with newforms admin

I recently converted a site with over 60 models to newforms admin. I like the seperation of the display from the defintion, but it does introduce quite a bit more typing which isn't in the spirit of Django DRY... I particular I got bored of typing admin.site.register(Model, ModelAdmin) Over and over again so I wrote this little bit of code which does a bit of introspection. It assumes that 1. You import all your models into your admin.py, ie from "myapp.models import *" 2. The admin class for Model is called ModelAdmin Put this snippet at the end of your admin.py I hope that saves someone a bit of typing!

  • admin
Read More
Author: ncw
  • -4
  • 4

ncw has posted 1 snippet.