[Answer]-Django Admin Using Button

1👍

It looks like you simply want to provide a link in your admin change list to go to a view that will carry out an action on the row – you don’t need a form to do this as you are simply doing a GET anyway with a link:

def method2(self):
    return '<a href="path/to/action/%s?param1=%s" target="_blank">Do Something</a>' % (self.id, label)

The reason you are having problems is that you can’t nest a form within a form (the entire change list in the django admin is already a form)

0👍

If you simply want to preform an action on a row. Use actions:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/

You can also make a field list_editable:
https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable

And if you want to invent your own stuff (why use a framework?):
Make a link with get parameters. Like Timmy O’Mahony suggested or point your link (without get parameters) to a custom model form.

Leave a comment