On Mon, Jul 13, 2009 at 2:48 PM, Mihail Lukin
<mihail.lu...@googlemail.com>wrote:

>
> Hello, everyone!
>
> django.forms allows me to define form class from model and render
> forms to html with just calling as_table method. Is there some module
> to do same thing with querysets? I guess its usage could look like
> this:
>
> class UserTable (tables.ModelTable):
>    class Meta:
>        model = User
>        fields = ['first_name', 'last_name', 'email']
>
> users = User.objects.all()
> table = UserTable(queryset=users)
> print table.thead
> '<th>First name</th><th>Last name</th><th>Email</th>'
>
> print table.tbody
> '<tr><td>John</td><td>Doe</td><td>uzohguk...@gmail.com</td></tr>
> <tr><td>Sarah</td><td>Connor</td><td>quoo9hu...@gmail.com</td></tr>'
>
> Thanks!
>
> >
>
There's a library named django-tables that does what you describe, it's on
launchpad I think.  I also have a module named django-filter that does the
filtering aspect of this (similar to the list_filter aspect of the admin),
but has no default rendering.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you want"
-- Me

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to