Skip to content

Possibility to attach queryset to number #2

Description

@jangeador

Could it be possible to keep a queryset or some sort of way that we could make the pivot number be attached to the records that produced the number to be able to make the number a list that would allow to drill down to the records. I was thinking of maybe adding the data or queryset as an item to each records dict, or whatever other way may be more practical.

Currently I am generating drilldown lists using django-filter and get parameters like this:

def build_url(*args, **kwargs):
    params = kwargs.pop('params', {})
    url = reverse(*args, **kwargs)
    if not params: return url

    qdict = QueryDict('', mutable=True)
    for k, v in params.items():
        if type(v) is list:
            qdict.setlist(k, v)
        else:
            qdict[k] = v

    return url + '?' + qdict.urlencode()

def render_as_links(self, request, record):
        params = {'performance': record['performance'], 'grade': record['grade'],
                  **self.request.GET}
        href = build_url('afb:table_proficiency_model_detail', params=params)
        return format_html(
            '<a href={href}>{text}</a>',
            href=href,
            text=value
        )

But it would be a lot easier if the queryset was already attached to the record. I hope this is not too out of scope.

Thanks in advance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions