I need to generate a URL with a list of object ids as query params.
i.e
Url will look something like admin/app/model/?id__in=1,2,3.
I have used reverse('admin:app_model_changelist', kwargs={id__in:<list_of_ids>}) which doesn't seem to work
I need to generate a URL with a list of object ids as query params.
i.e
Url will look something like admin/app/model/?id__in=1,2,3.
I have used reverse('admin:app_model_changelist', kwargs={id__in:<list_of_ids>}) which doesn't seem to work
reverse() won't generate query params. You can just try the string formatting as
path = reverse('admin:app_model_changelist')
result = '%s?id__in=%s' % (path, ','.join(map(str,list_of_ids)))
Using kwargs you will have to provide a dictionary with the named arguments, as specified in your URL configuration.
Try instead to use args, like described in the django documentation on resolve():
If the URL accepts arguments, you may pass them in args. For example:
from django.urls import reverse def myview(request): return HttpResponseRedirect(reverse('arch-summary', args=[1945]))