You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using these action forms, what is the right way to write tests?
I tried to follow some of the examples from this StackOverflow post for testing admin actions generically, and test for a redirect to the admin/django_admin_action_forms/action_form.html template, but I got some weird errors like:
> action = request.POST.getlist("action")[int(request.POST.get("index"))]
E TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Just for experimentation, I hard-coded a {index: 0} into my POST data and got it to pass, but I don't really understand what that would be doing or if I'm actually testing anything correctly.
Then, separately, what would be the right way to test the form submission?
The text was updated successfully, but these errors were encountered:
So, the index is used when there are multiple AdminForms (Django ones aka django.contrib.admin.helpers.AdminForm) on single change list page, which contain the information about a selected action. But when there are multiple of them, e.g. when one uses actions_on_bottom on a ModelAdmin, the POST data that is being sent might look like this:
Then, we can determine which "Go" button was clicked (the index POST value) and by that get the action name which was selected.
When using these action forms, what is the right way to write tests?
I tried to follow some of the examples from this StackOverflow post for testing admin actions generically, and test for a redirect to the
admin/django_admin_action_forms/action_form.html
template, but I got some weird errors like:Just for experimentation, I hard-coded a
{index: 0}
into my POST data and got it to pass, but I don't really understand what that would be doing or if I'm actually testing anything correctly.Then, separately, what would be the right way to test the form submission?
The text was updated successfully, but these errors were encountered: