Source

django-helper / django_helper / templates / admin / django_helper / admin.txt

from django.contrib import admin
from models import {{model}}

{% if model.inlines %}class {{model.inlines}}Inline(admin.TabularInline):
    model = {{model.inlines}}{% endif %}
class {{model}}Admin(admin.ModelAdmin):
{% if model.date_hierarchy %}
    date_hierarchy = '{{model.date_hierarchy}}'{% endif %}{% if model.exclude.count > 0 %}
    exclude = ({% for field in model.exclude.all %}'{{field}}', {% endfor %}){% endif %}{% if model.fields.count > 0 %}
    fields = ({% for field in model.fields.all %}'{{field}}', {% endfor %}){% endif %}{% if model.filter_horizontal.count > 0 %}
    filter_horizontal = ({% for field in model.filter_horizontal.all %}'{{field}}', {% endfor %}){% endif %}{% if model.filter_vertical.count > 0 %}
    filter_vertical = ({% for field in model.filter_vertical.all %}'{{field}}', {% endfor %}){% endif %}{% if model.inlines %}
    inlines = [{{model.inlines}}Inline,]{% endif %}{% if model.list_display.count > 0 %}
    list_display = ({% for field in model.list_display.all %}'{{field}}', {% endfor %}){% endif %}{% if model.list_filter.count > 0 %}
    list_filter = ({% for field in model.list_filter.all %}'{{field}}', {% endfor %}){% endif %}{% if model.raw_id_fields.count > 0 %}
    raw_id_fields = ({% for field in model.raw_id_fields.all %}'{{field}}', {% endfor %}){% endif %}

admin.site.register({{model}}, {{model}}Admin)