Hello, everyone!
I've released 1.0 beta of the app:
https://github.com/05bit/django-smarter
It helps with adding generic views. Actually, I've build this app for
one of my projects, which is 80% based on generic views, and it seemed
very useful for that particular case :)
As my project evolved and became more complicated, I've got another
look on what an API for library should like, so today I've published
completely renewed version of the app and migrated my project to it.
My approach is to have all generic views in a single class, like
GenericViews class has 'add', 'index', 'edit', 'remove' and 'details'
methods. And to include generic views for some model in a simplest
case you should just write something like this:
import smarter
from myapp.models import Page
site = smarter.Site()
site.register(smarter.GenericViews, Page)
urlpatterns = patterns('',
url(r'^', include(site.urls)),
# other urls ...
)
And for more custom generic views you may subclass from GenericViews
and define options:
class PageViews(smarter.GenericViews):
model = Page
options = {
'add': {
'form': NewPageForm,
'decorators': (login_required,)
},
'edit': {
'form': EditPageForm,
'decorators': (login_required,)
},
'remove': {
'decorators': (login_required,)
}
}
Wide range of options are available, so I hope you'll find it useful
for some cases :)
Regards,
Alex
///
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment