I change the admin view like described in: How Do I Show Django Admin Change List View of foreign key children?
I have Customer -> Project -> Action I get all actions for a project by this method:
def related_actions(self, obj):
from django.core import urlresolvers
url = urlresolvers.reverse("admin:workflow_action_changelist")
lookup = u"project__exact"
text = obj.name
return u"<a href='%s?%s=%d'>%s</a>" % (url, lookup, obj.pk, text)
Now i want to customize the addlink in the change_list. The admin change_list is overwritten by a template in /workflow/templates/admin/workflow/action/change_list.html But all three models use the same template. So i think there must be a better solution as harcode param in the template When i change the line
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
to
<a href="add/?actionstatus=5" class="addlink">
the actioncategory is preselected in the new action form. But how could i override the addlink in each model.
I must get the actionstatus by the param in the projectsview:
/workflow/action/?project__exact=5
Any suggestions?
Is there something like this pseudo for use in action model ?
def add(self)
get param projectid from url
return "<a href='/workflow/action/add/%s' target='_blank'>Add Action</a>" % (parent.project id)