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

Possibility to attach queryset to number #2

Open
jangeador opened this issue Oct 18, 2017 · 0 comments
Open

Possibility to attach queryset to number #2

jangeador opened this issue Oct 18, 2017 · 0 comments

Comments

@jangeador
Copy link

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.

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

No branches or pull requests

1 participant