Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tweaking file structure for application-level templates

  • Loading branch information...
commit 2b9962fac1ff919b6e4d44c3f22163d9de8be24f 1 parent 91da533
@philchristensen philchristensen authored
View
5 README
@@ -1,7 +1,8 @@
To get inline Admin Previews in the list view
-1) Inherit from PreviewAdmin in your ModelAdmin
-2) In your model's template directory, create a folder called preview, and create a template for that model's preview
+1) Add adminpreview to your INSTALLED_APPS
+2) Inherit from PreviewAdmin in your ModelAdmin
+3) In your model's template directory, create a folder called preview, and create a template for that model's preview
Example for model Article
View
4 adminpreview/static/css/admin/base.css
@@ -0,0 +1,4 @@
+.previewslide {
+ cursor:pointer;
+ cursor:hand;
+}
View
21 adminpreview/static/js/jquery.adminpreview.js
@@ -0,0 +1,21 @@
+$(document).ready(function(){
+ $(".previewslide").click(function(){
+ $.ajax({
+ url:$(this).attr('id'),
+ context: $(this).parent().parent(),
+ success:function(data){
+ var $html = $(data);
+ $('.previewed').each(function(){
+ $(this).remove();
+ });
+
+ if(!$html.hasClass('previewed')){
+ $html.addClass('previewed');
+ }
+
+ $html.addClass($(this.context).attr('class'));
+ $(this.context).after($html);
+ }
+ });
+ });
+});
View
25 examples/myapp/templates/preview/article.html
@@ -0,0 +1,25 @@
+<tr>
+ <td colspan="5">
+ <table>
+ <tr>
+ <td>
+ <img src="{{ object.image.featured.url }}">
+ </td>
+ <td>
+ Abstract:<br/>
+ {{ object.abstract }}
+ </td>
+ <td>
+ Author: {{ object.author }}<br/>
+ Published: {{ object.published_date }}<br/>
+ Category: {{ object.category }}<br/>
+ <br/>
+ Tags: {% for tag in object.get_tags %}
+ {{ tag }}
+ {% if not forloop.last %}, {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ </table>
+ </td>
+</tr>
Please sign in to comment.
Something went wrong with that request. Please try again.