Last active
August 29, 2015 13:57
-
-
Save cassus/9757672 to your computer and use it in GitHub Desktop.
Action button on django model edit page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyAdmin(admin.ModelAdmin): | |
def response_change(self, request, obj): | |
if "_activate_and_send_email" in request.POST: | |
self.activate_account_and_send_email(request, (obj,)) | |
return HttpResponseRedirect(request.path) | |
return super().response_change(request, obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In templates/admin/submit_line.html | |
... | |
{% if opts.model_name == "myModel" %}<input type="submit" value="{% trans 'Activate and send email' %}" class="btn btn-warning" name="_activate_and_send_email" {{ onclick_attrib }}/>{%endif%} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment