asifpy / django-crudbuilder

Generic CRUD implementation in Django
https://django-crudbuilder.readthedocs.org/en/latest/index.html
Apache License 2.0
193 stars 67 forks source link

Unclear on TableBuilder #39

Closed oziek88 closed 7 years ago

oziek88 commented 7 years ago

I'm looking to add checkboxes to my table in list.html. I saw the commented out override instructions. But I'm still a little unclear to how it ties into my ViewBuilder. Do I reference the CustomTable in a specific way in views? Thank you.

This is my tables.py:

builder = TableBuilder('sorter', 'foo', FooCrud)
CheckboxFooTable = builder.generate_table()
class CustomFooTable(CheckboxFooTable):
    selection = tables.CheckBoxColumn(accessor='pk')

    class Meta:
        model = foo
        attrs = {'id': 'foo-crud-table'}
                sequence = ('selection', 'name', 'gender')
asifpy commented 7 years ago

You can create your own custom table (as shown here Custom table example), and set the same table for custom_table2 field in your crud class.

Check out my latest commit where I added same example on how to handle custom tables

Feel free to close this when you don't have anymore questions.

oziek88 commented 7 years ago

Thank you for the quick response. That makes a lot more sense to me. I'm having an issue with importing my table to crud though. I haven't had this issue with any other .py files. It's like crud.py won't allow the import of anything from my tables.py file. Have you experienced this, or should I do some digging?

asifpy commented 7 years ago

There shouldn't be any problem, you can check in example crud.py where I'm importing CustomPersonTable in crud.py and everything is working fine.

Can you please share your crud.py here.

oziek88 commented 7 years ago

It was a blooper on my part. I was importing a crudbuilder file into my tables.py. All figured out. Thank you so much