Skip to content

Commit

Permalink
Help for templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Socol committed Mar 4, 2011
1 parent 4198380 commit 5609ec4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions adminplus/templates/adminplus/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "admin/base_site.html" %}

{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url admin:index %}">Home</a> &rsaquo; {{ title }}
</div>
{% endblock %}
44 changes: 44 additions & 0 deletions docs/custom-admin-views.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
===========================
Creating Custom Admin Views
===========================

Any view can be used as a custom admin view in AdminPlus. All the normal rules
apply: accept a request and possibly other parameters, return a response, and
you're good.

Making views look like the rest of the admin is pretty straight-forward, too.


Extending the Admin Templates
=============================

AdminPlus contains an base template you can easily extend. It includes the
breadcrumb boilerplate. You can also extend ``admin/base_site.html`` directly.

Your view should pass a ``title`` value to the template to make things pretty.

Here's an example template::

{# myapp/admin/myview.html #}
{% extends 'adminplus/base.html' %}

{% block content %}
{# Do what you gotta do. #}
{% endblock %}

That's pretty much it! Now here's how you use it::

# myapp/admin.py
# Using AdminPlus
from django.contrib import admin
from django.shortcuts import render_to_response
from django.template import RequestContext

def myview(request):
# Fanciness.
return render_to_response('myapp/admin/myview.html',
{'title': 'My View'},
RequestContext(request, {}))
admin.site.register_view('mypath', myview, 'My View')

Voila! Instant custom admin page that looks great.

0 comments on commit 5609ec4

Please sign in to comment.