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!

--~--~---------~--~----~------------~-------~--~----~
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