Created
February 7, 2013 21:25
-
-
Save lambdamusic/4734320 to your computer and use it in GitHub Desktop.
Django: Django: adding new admin_tags
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
# FIRST: | |
from django import template | |
from poms.pomsapp import models | |
register = template.Library() | |
# for People template | |
@register.inclusion_tag('admin/snippets/personfactoid_info.html') | |
def display_personfactoids(person_id): | |
person = models.Person.objects.get(id__exact=person_id) | |
# factoids = models.Factoids.objects.filter(people=person) | |
return { 'person': person } | |
## SECOND: | |
{% if person.assocfactoidperson_set.all %} | |
<b>Person associated to factoids:</b></br /> | |
<table> | |
<tr> | |
<th>Record ID</th> | |
<th>Type</th> | |
<th>Short Summary</th> | |
<th>Role</th> | |
<th>Source</th> | |
</tr> | |
{% for a in person.assocfactoidperson_set.all %} | |
<tr> | |
<td>{{a.factoid.id}}</td> | |
<td>{{a.factoid.get_right_subclass.0}}    </td> | |
<td><a href="{% url factoid_detail a.factoid.id %}" title="click to show">{{a.factoid}}</a></td> | |
<td>{{a.role}}</td> | |
<td><a href="{% url source_detail a.factoid.sourcekey.id %}" title="click to show">{{a.factoid.sourcekey}}</a></td> | |
</tr> | |
{% endfor %} | |
</table> | |
<br /><hr><hr><hr><br /> | |
{% endif %} | |
## THIRD | |
........ | |
{% block related_items_block %}{% endblock %} | |
........ | |
## FOURTH | |
{% extends "admin/change_form.html" %} | |
{% load myadmin_tags %} | |
{% block related_items_block %} | |
<h2>Additional information:</h2><br /> | |
{% if object_id %} | |
{% display_personfactoids object_id %} | |
{% endif %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment