Here it's the code working :)

class TableDataGrid(grids.DataGrid):
  # This would be different for each instance of grids.DataGrid
   sortable = ['pk', 'en_name', 'region']

   model = models.Country
   meta = model._meta

   #data = {}  # !!! To delete
   fields = []
   for f in meta._fields():
      name =
      if 'id' in name:
         name = 'pk'

      if name in sortable:
         exec("%s = grids.Column(%r, sortable=True)" %
              (name, unicode(f.verbose_name)))
         exec("%s = grids.Column(%r)" % (name, unicode

      # ### !!! To delete
      # I'm using exec() because with a dictionary it says:
      # 'list index out of range'
      #data[name] = "grids.Column(%r)" % unicode(f.verbose_name)
      # ### !!!

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

On 22 feb, 11:02, Christian Hammond <> wrote:
> Providing a custom DataGrid like this would be a nice addition to Djblets. I
> probably won't be able to spend any time fine-tuning this, but it looks like
> you have a good start. If we got this polished up, I'd definitely include it
> in Djblets.

You received this message because you are subscribed to the Google Groups 
"reviewboard" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to