# Path: popupcrud/views.py
# ORDER_VAR = 'o'


from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields.related import RelatedField
from django.forms.utils import pretty_name
from django.template import Library
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
from django.utils.html import format_html
from django.utils.text import capfirst
from django.contrib.admin.utils import lookup_field, label_for_field as lff
from bootstrap3.renderers import FormRenderer, FormsetRenderer
from bootstrap3.bootstrap import get_bootstrap_setting
from bootstrap3.forms import render_field
from popupcrud.views import ORDER_VAR
import six
        o_list_primary = []  # URL for making this field the primary sort
        o_list_remove = []  # URL for removing this field from sort
        o_list_toggle = []  # URL for toggling order type for this field

        def make_qs_param(t, n):
            return ('-' if t == 'desc' else '') + str(n)

        for j, ot in ordering_field_columns.items():
            if j == i:  # Same column
                param = make_qs_param(new_order_type, j)
                # We want clicking on this header to bring the ordering to the
                # front
                o_list_primary.insert(0, param)
                o_list_toggle.append(param)
                # o_list_remove - omit
            else:
                param = make_qs_param(ot, j)
                o_list_primary.append(param)
                o_list_toggle.append(param)
                o_list_remove.append(param)

        if i not in ordering_field_columns:
            o_list_primary.insert(0, make_qs_param(new_order_type, i))

        yield {
            "text": text,
            "sortable": True,
            "sorted": sorted_field,
            "ascending": order_type == "asc",
            "sort_priority": sort_priority,

# Path: popupcrud/views.py
# ORDER_VAR = 'o'


# Path: popupcrud/templatetags/popupcrud_list.py
from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields.related import RelatedField
from django.forms.utils import pretty_name
from django.template import Library
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
from django.utils.html import format_html
from django.utils.text import capfirst
from django.contrib.admin.utils import lookup_field, label_for_field as lff
from bootstrap3.renderers import FormRenderer, FormsetRenderer
from bootstrap3.bootstrap import get_bootstrap_setting
from bootstrap3.forms import render_field
from popupcrud.views import ORDER_VAR
import six

        o_list_primary = []  # URL for making this field the primary sort
        o_list_remove = []  # URL for removing this field from sort
        o_list_toggle = []  # URL for toggling order type for this field

        def make_qs_param(t, n):
            return ('-' if t == 'desc' else '') + str(n)

        for j, ot in ordering_field_columns.items():
            if j == i:  # Same column
                param = make_qs_param(new_order_type, j)
                # We want clicking on this header to bring the ordering to the
                # front
                o_list_primary.insert(0, param)
                o_list_toggle.append(param)
                # o_list_remove - omit
            else:
                param = make_qs_param(ot, j)
                o_list_primary.append(param)
                o_list_toggle.append(param)
                o_list_remove.append(param)

        if i not in ordering_field_columns:
            o_list_primary.insert(0, make_qs_param(new_order_type, i))

        yield {
            "text": text,
            "sortable": True,
            "sorted": sorted_field,
            "ascending": order_type == "asc",
            "sort_priority": sort_priority,

            "url_primary": view.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),