Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method get_template_names was added to SingleTableView #49

Closed
wants to merge 1 commit into from

Conversation

dramon
Copy link

@dramon dramon commented Feb 1, 2012

I added method get_template_names copied from MultipleObjectTemplateResponseMixin to SingleTableView because I miss this behavior when I moved my View from ListView class to SingleTableView.

@bradleyayers
Copy link
Collaborator

Thanks for the suggestion and pull request, but I disagree with your implementation. Copying code verbatim from Django is very much the wrong approach. This could be easily solved by making SingleTableView inherit from ListView, rather than BaseListView (which I will do).

@dramon
Copy link
Author

dramon commented Feb 2, 2012

OK. I agree it's much more better :)
Unfortunately I don't know the whole background/idea about django-tables2 and I didn't want to change one of base classes.

Yesterday I play more with SingleTableView and again I may be don't know some important but why is there table_data/get_table_data if MultipleObjectMixin has it's own implementation of queryset/get_query_set??
And second thing - paginator. It's also implemented in MultipleObjectMixin and use "page" GET parameter and calling "table.paginate(page=self.request.GET.get("page", 1))" does the same thing again.

I would like to improve SingleTableView but I would like to know if it is a good idea to change it closer to ListView?? My opinion is that SingleTableView is the same as ListView and only table_class make sense to add. In ListView is queryset, paginator, paginate_by and I would like to use them.

Thanks for every advice.

@bradleyayers
Copy link
Collaborator

get_table_data is a hook that allows you to populate the table with any data you like. Its implementation in SingleTableMixin falls back to looking for data from MultipleObjectMixin however. Pagination is built into Table, and I recommend using the RequestConfig class to configure it. This is one area that could be improved with SingleTableMixin -- make it support RequestConfig.

The difference between SingleTableView and ListView is that the table view adds a table to the list view. It doesn't force you to populate the table with the same data that the list displays. For example you might have a list of objects that are the responsibility of the ListView, but then you might want a table displaying the history of changes (ala admin log).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants