Building a datagrid is too verbose and we're repeating data that it
has been already set in the models. So could use those metadata.

-----------------
class TableDataGrid(grids.DataGrid):
   model = models.Table
   meta = model._meta
   fields = [field.name for field in meta._fields()]

   # ### This faills. But the idea is to execute dinamically all
fields.
   data = {}
   for field in meta._fields():
      name = field.name
      if 'id' in name:
         name = 'pk'
      data[name] = "grids.Column(%s)" % unicode(field.verbose_name)
   # ###

   def __init__(self, request):
      grids.DataGrid.__init__(self, request, self.model.objects.all(),
 
self.meta.verbose_name_plural.title)
      self.default_sort = self.meta.ordering
      self.default_columns = self.fields
-----------------

To working with metada:
http://www.b-list.org/weblog/2007/nov/04/working-models/


Thanks for this application. It should be in django.contribs because
there are many people that needs anything so (and it's more powerfull
than databrowse).

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

Reply via email to