I am using a method on a model class to show a button on the changelist form. I have a very peculiar problem, Only the first button does not work. Even if I have 2 separate methods of buttons then the left will not work of the 1st row. I check out the source code of the page and the error is
Saw a form start tag but there was already an active form element. Nested tags are not allowed. Ignoring the tag.
On further inspection I found
<form id="grp-changelist-form" action="" method="post"><input type='hidden' name='csrfmiddlewaretoken' value='l6Z2ez9F00XMVQjp0KIRIKgRIcQ9nnQc' />
this form to be open. Any suggestions to overcome this problem. Relevent codes are
Class MyModel(models.Model):
.
.
def method1(self):
return '<form action="path/to/action1" method="get"><input type="submit" value="%s"></form>' % (self.id, label)
def method2(self):
return '<form action="path/to/action2" method="get"><input type="submit" value="%s"></form>' % (self.id, label)
then using the two methods on list_display of admin. I am using Grappelli.