Python django_tables2.Table() Examples

The following are 2 code examples of django_tables2.Table(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django_tables2 , or try the search function .
Example #1
Source File: plugin_run.py    From ontask_b with MIT License 6 votes vote down vote up
def create_model_table(
    request: http.HttpRequest,
    workflow: models.Workflow,
    is_model: bool,
):
    """Create the table of plugins that are models.

    :param request: Received request
    :param workflow: Workflow being processed
    :param is_model: Is the object a model?
    :return: Table with available model plugins
    """
    # Traverse the plugin folder and refresh the db content.
    refresh_plugin_data(request)

    return PluginAvailableTable(
        models.Plugin.objects.filter(
            is_model=is_model,
            is_verified=True,
            is_enabled=True),
        orderable=False,
        user=request.user,
        workflow=workflow) 
Example #2
Source File: tables.py    From django-crudbuilder with Apache License 2.0 6 votes vote down vote up
def generate_table(self):
        model_class = self.get_model_class()

        detail_url_name = '{}-{}-detail'.format(
            self.app, custom_postfix_url(self.crud(), self.model)
        )

        main_attrs = dict(
            pk=tables.LinkColumn(detail_url_name, args=[A('pk')])
        )

        meta_attrs = dict(
            model=model_class,
            fields=('pk',) + self.tables2_fields if self.tables2_fields else ('pk',),
            attrs={
                "class": self.tables2_css_class,
                "empty_text": "No {} exist".format(plural(self.model))
            })

        main_attrs['Meta'] = type('Meta', (), meta_attrs)
        klass = type(
            model_class_form(self.model + 'Table'),
            (tables.Table,),
            main_attrs
        )
        return klass