# How to create a Django Admin link with preselected objects and a pre-filled action?

**URL:** <https://forum.djangoproject.com/t/how-to-create-a-django-admin-link-with-preselected-objects-and-a-pre-filled-action/36570>\
**Category:** Using Django\
**Created:** [November 19, 2024, 10:55am UTC](https://forum.djangoproject.com/t/how-to-create-a-django-admin-link-with-preselected-objects-and-a-pre-filled-action/36570 "2024-11-19T10:55:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevMaster15](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/devmaster15/32/15869_2.png) [@DevMaster15](https://forum.djangoproject.com/u/DevMaster15)\
**Post date:** [November 19, 2024, 10:55am UTC](https://forum.djangoproject.com/t/how-to-create-a-django-admin-link-with-preselected-objects-and-a-pre-filled-action/36570/1 "2024-11-19T10:55:46Z")

</div>

I am trying to generate a link that takes users to the Django Admin page for a specific model, with certain objects already selected and an action pre-filled in the dropdown menu.

Here’s what I’ve tried so far:

```auto
def get_admin_action_link(record, action):
    app_label = record._meta.app_label
    model = record._meta.model_name
    id = record.id
    env = f"{settings.env}.myurl.com" if settings.env else "http://localhost:8000"
    return f"{env}/admin/{app_label}/{model}?action={action}&_selected_action={id}"

```

The generated link looks like this:

```auto
http://localhost:8000/admin/app/mymodel?action=process&_selected_action=591

```

However, when I click on the link, it only takes me to the changelist view of the model in the admin. The objects aren’t selected, and the action isn’t pre-filled.

---

<div class="post-metadata">

**Author:** ![philgyford](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/philgyford/32/14295_2.png) [@philgyford](https://forum.djangoproject.com/u/philgyford)\
**Post date:** [November 19, 2024, 12:04pm UTC](https://forum.djangoproject.com/t/how-to-create-a-django-admin-link-with-preselected-objects-and-a-pre-filled-action/36570/2 "2024-11-19T12:04:29Z")

</div>

First, for generating Admin URLs, I’d use `reverse()`:

```python
reverse(f"admin:{app_label}_{model}_changelist")) + "?action=..."

```

I think that should be better if you change your overall Admin URL in the future.

But, as you’ve discovered, it doesn’t look like it’s possible to pre-set the action select field and checkboxes via a GET request. I tried to look through the Django code for what’s happening, but it’s a bit beyond me. It looks like something checks the URL parameters and redirects if it thinks they’re not valid ([the redirect happens here](https://github.com/django/django/blob/17e544ece7e51c5eaeff9bdadc3de263fdd98dee/django/contrib/admin/options.py#L2039)).

Which is a shame, because you can do a similar thing with the add/change Admin views, pre-setting field values in a GET URL. Maybe there’s a good reason why it doesn’t work for the changelist.
