Answer the question
In order to leave comments, you need to log in
How to get current url in admin.py?
admin.py
....
from django.http.request import HttpRequest
....
class ProductAdmin(TranslatableAdmin):
....
list_display = ("title", "category", "_stat", "_actions")
.......
def _actions(self, obj):
print(HttpRequest.META['HTTP_HOST'])
return """
<a href="{}" class="btn btn-primary"><i class="fa fa-pencil"></i></a>
<a href="#" name="delete_item" id="20" data-toggle="modal" data-target="#deleteModel" class="btn btn-danger"><i class="fa fa-trash"></i></a>
""".format()
Answer the question
In order to leave comments, you need to log in
https://docs.djangoproject.com/en/1.9/ref/request-...
self.request.path should contain what you think (not really necessary) what you need
Actually you need to learn https://docs.djangoproject.com/en/dev/ref/contrib/...
name=delete_item - better to make it a button - if it is ajaxed (don't forget to check user rights before deleting!)
id - need to be done with your own prefix, so as not to interfere with the main admin panel, in general, everything you do in the admin panel should have your prefix
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question