I am using a model class to show a button on the changelist form. I have a very strange problem, only the first button does not work. Even if I have two different ways, then 1 row will not work on the left. I check the source code of the page and the error is
A form tag I got a look at the next inspection
& Lt; Form id = "grp-changelist-form" action = "" method = "post" & gt; & Lt; Input type = 'hidden' name = 'csrfmiddle titan' value = 'l6Z2ez9F00XMVQjp0KIRIKgRIcQ9nnQc' / & gt; This form is to be open. There are no suggestion reliability codes to overcome this problem
Class MyModel (models.Model) :. . Def = "% s" & gt; & Lt; / Form & gt; Def Method 1 (self): Return '& lt; Form action = "path / to / action1" method = "get" & gt; & Lt; Input type = "submit"% (Self.id, label) def method2 (self): Return '& lt; Form action = "path / to / action2" method = "get" & gt; & Lt; Input type = "submit" value = "% s" & gt; & Lt; / Form & gt; '% (Self.id, label) Then on admin's list_display using two methods. I'm using Grappelli
It seems that you just want to provide a link in your administrator change list, go to a view The line that will take any action - you do not need a form to do this because you are just getting in a way with a link:
def method2 (self): Return '& lt; A href = "path / to / action /% s? Param1 =% s" target = "_ blank" & gt; Do something & lt; / A & gt; % (Self.id, label) You are having problems (the complete change list in the Django admin is already a form)
No comments:
Post a Comment