oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
425 stars 81 forks source link

django-tables2 #70

Closed fjbardelli closed 5 years ago

fjbardelli commented 6 years ago

it is possible to use django-tables2, to make the list

luisza commented 6 years ago

Wooo this insert a lot of overhead and weird behavior that I think it's not recomendable but it's possible to extends cruds to support django-tables2 but i don't be who code this feature

fjbardelli commented 6 years ago

Thank.

fjbardelli commented 6 years ago

With the following code I am trying to implement Django-Tables2

from django_tables2 import Table from django_tables2 import SingleTableMixin

from django_tables2.columns import Column

class TBLCRUDView(CRUDView):

class Tabla(tables.Table):
    Nombre = Column('Nombre')
    Codigo = Column('Codigo')

model = Vendedor
paginate_by = 5
paginate_position = 'Both'
list_filter = ['Curso']
search_fields = ['Nombre__icontains']

template_name = 'django_tables2/bootstrap.html'
table_class = Tabla

def get_list_view(self):
    View = super(UserCRUDView, self).get_list_view()

    class UListView(SingleTableMixin, View):
        #model = Zona
        #table_class = ZonaTable
        if self.table_class:
            table_class = self.table_class

        def get_queryset(self):
            queryset = super(UListView, self).get_queryset()
            #queryset = queryset.filter(user=self.request.user)
            return queryset
    return UListView
    #return View
luisza commented 6 years ago

Hi, as you see it's easy to implement for your case, but try to think how to create Tabla automatically for all any model that user wants, thats the complicate part.

class Tabla(tables.Table):
    Nombre = Column('Nombre')
    Codigo = Column('Codigo')

If you need help with your example I can help you, but if you try to implement the generic part maybe a PR is the best option.

telenieko commented 5 years ago

Closing issue due to lack of activity and the main point already cleared by @luisza back in 2018.