On Dec 13, 9:31 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > That sounds like the only way. If you want to see batchadmin's changes, > you have to extend from that.
Thank you, I have made batchadmin find its media in my development setup. My change_list.html, which now extends batchadmin/change_list.html, is not selected for rendering/has no effect in the filesystem layout I would expect to work, and recursion error problems in next most likely layout. The following layout results in a recursion error: $ tree /path/to/acme/acme/widgets/templates /path/to/acme/acme/widgets/templates |-- admin | `-- widgets | `-- widget | `-- change_form.html |-- batchadmin | `-- change_list.html `-- widgets |-- detail.html `-- index.html Both layouts below have no effect on rendering the searchbar customization, but generate no recursion error: $ tree /path/to/acme/acme/widgets/templates /path/to/acme/acme/widgets/templates |-- admin | `-- widgets | `-- widget | `-- change_form.html |-- batchadmin | `-- widgets | `-- widget | `-- change_list.html `-- widgets |-- detail.html `-- index.html $ tree /path/to/acme/acme/widgets/templates /path/to/acme/acme/widgets/templates |-- admin | `-- widgets | `-- widget | |-- change_form.html | `-- change_list.html |-- batchadmin `-- widgets |-- detail.html `-- index.html The last is the layout which works prior to the batchadmin and changes to extend batchadmin/change_list.html. The following is the djang-batchadmin batchadmin/change_list template extending admin/change_list: $ cat /path/to/django-batchadmin/batchadmin/templates/batchadmin/ change_list.html {% extends "admin/change_list.html" %} {% load batch_list %} {% block extrahead %}{{ block.super }}{{ batchadmin_media }}{% endblock %} {% block result_list %} <form id="batch-action-form" method="post" action=""> {% if batchadmin_on_top or not cl.paginator.count %}{% actions %} {% endif %} {{ block.super }} {% if batchadmin_on_bottom and cl.paginator.count %}{% actions %} {% endif %} </form> {% endblock %} And per http://www.djangosnippets.org/snippets/1239/ and this thread, the widgets app custom change_list.html extends batchadmin/ change_list.html: $ cat /path/to/acme/acme/widgets/templates/admin/widgets/widget/ change_list.html {% extends "batchadmin/change_list.html" %} {% load adminmedia %} {% load i18n %} {% load admin_modify %} {% block extrahead %}{{ block.super }} <script type="text/javascript" src="../../jsi18n/"></script> <script type="text/javascript" src="/site_media/js/ jquery-1.2.6.min.js"></script> {{ media }} <script type="text/javascript"> jQuery.fn.counter = function() { // setup initial counter display $(this).each(function() { var max = $(this).attr('size'); var val = $(this).attr('value'); var cur = 0; if(val) // value="", or no value at all will cause an error cur = val.length; var left = max-cur; $(this).after("<span class='counter'>" + left.toString()+"</span> characters remaining"); // Style as desired var c = $(this).next(".counter"); c.css("margin-left","10px"); c.css("padding", "0 3px 0 3px") c.css("border", "1px solid #ccc") if(left <= 10) c.css("background","#F4F379"); else c.css("background","none"); // setup counter to change with keystrokes $(this).keyup(function(i) { var max = $(this).attr('size'); var val = $(this).attr('value'); var cur = 0; if(val) cur = val.length; var left = max-cur; var c = $(this).next(".counter"); c.text(left.toString()); if(left <= 10) c.css("background","#F4F379"); else c.css("background","none"); return this; }); }); return this; } $(document).ready(function() { $("#searchbar").counter(); }); //--> </script> {% endblock %} {% block search %} {% if cl.search_fields %} <div id="toolbar"><form id="changelist-search" action="" method="get"> <div><!-- DIV needed for valid HTML --> <label for="searchbar"><img src="{% admin_media_prefix %}img/admin/ icon_searchbox.png" alt="Search" /></label> <input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" /> <input type="submit" value="{% trans 'Go' %}" /> {% if show_result_count %} <span class="small quiet">{% blocktrans count cl.result_count as counter %}1 result{% plural %}{{ counter }} results{% endblocktrans %} (<a href="?{% if cl.is_popup %}pop=1{% endif %}">{% blocktrans with cl.full_result_count as full_result_count %}{{ full_result_count }} total{% endblocktrans %}</a>)</span> {% endif %} {% for pair in cl.params.items %} {% ifnotequal pair.0 search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endifnotequal %} {% endfor %} </div> </form></div> <script type="text/javascript">document.getElementById ("searchbar").focus();</script> {% endif %} {% endblock %} The above template works correctly before the addition of batchadmin to the setup below (and the change to extends). I've included a lot of setup detail below, not sure which may be relevant to the problem at hand: Thanks for any suggestions. Setup Details ------------- I'm using a site_media to develop locally without any external http server. The setup will become more conventional when deployment is imminent. /path/to/acme/acme (master) $ python manage.py runserver Validating models... 0 errors found Django version 1.0.2 final, using settings 'acme.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. "GET /widgetadmin/widgets/widget/ HTTP/1.1" 200 11228 "GET /site_media/batchadmin/css/batchadmin.css HTTP/1.1" 200 685 "GET /site_media/batchadmin/js/jquery.js HTTP/1.1" 200 55774 "GET /site_media/batchadmin/js/batchadmin.js HTTP/1.1" 200 1411 $ cat /path/to/acme/acme/settings.py (excerpts): PROJDIR = dirname(abspath(__file__)) DEBUG = True MEDIA_ROOT = join(PROJDIR, 'media') MEDIA_URL = '' ADMIN_MEDIA_PREFIX = '/media/' BATCHADMIN_MEDIA_PREFIX = '/site_media/batchadmin/' STATIC_DOC_ROOT = join(PROJDIR, 'media') ROOT_URLCONF = 'acme.urls' TEMPLATE_DIRS = ( join(PROJDIR, 'batchadmin', 'templates'), join(PROJDIR, 'widgets', 'templates'), join(PROJDIR, 'templates'),) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'batchadmin', 'acme.widgets',) The project-level urls.py includes the app-level widgets/urls.py, and serves site_media statically if DEBUG: $ cat /path/to/acme/acme/urls.py from django.conf.urls.defaults import * from django.contrib import admin from django.conf import settings # The next two lines enable the admin and load each admin.py file: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^', include('widgets.urls')), (r'^admin/(.*)', admin.site.root), ) # Serve static media if DEBUG: if settings.DEBUG: urlpatterns += patterns('', (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), ) $ cat /path/to/acme/acme/widgets/urls.py from django.conf.urls.defaults import * from admin import admin_site urlpatterns = patterns('widgets.views', (r'^widgets/$', 'index'), (r'^widgetadmin/(.*)', admin_site.root), (r'^$', 'index'), (r'^(?P<id>\d+)/$', 'detail'), ) The following are file tree listings for reference. This project uses a non-system python-2.5 virtualenv: The project-level tree with contained widgets app-in-development: $ tree /path/to/acme/acme |-- __init__.py |-- widgets | |-- __init__.py | |-- admin.py | |-- fixtures | | `-- acmesetup.json | |-- management.py | |-- models.py | |-- sql | | |-- widget.sql | | `-- user.sql | |-- templates | | |-- admin | | | `-- widgets | | | `-- widget | | | |-- change_form.html | | | `-- change_list.html | | `-- widgets | | |-- detail.html | | `-- index.html | |-- tests.py | |-- urls.py | `-- views.py |-- acme.db |-- manage.py |-- media | |-- batchadmin -> /path/to/django-batchadmin/batchadmin/media | `-- js | `-- jquery-1.2.6.min.js |-- settings.py |-- templates | `-- admin | |-- base.html | `-- base_site.html `-- urls.py The django-batchadmin checkout, symlinked in the pythonpath below and media above: $ tree /path/to/django-batchadmin/ /path/to/django-batchadmin/ |-- VERSION |-- batchadmin | |-- __init__.py | |-- __init__.pyc | |-- admin.py | |-- admin.pyc | |-- forms.py | |-- forms.pyc | |-- media | | |-- css | | | `-- batchadmin.css | | `-- js | | |-- batchadmin.js | | `-- jquery.js | |-- templates | | `-- batchadmin | | |-- actions.html | | `-- change_list.html | |-- templatetags | | |-- __init__.py | | |-- __init__.pyc | | |-- batch_list.py | | `-- batch_list.pyc | |-- util.py | `-- util.pyc |-- ez_setup.py `-- setup.py The non-system python-2.5 virtualenv site-packages directory: $ tree -L 2 /path/to/acme/lib/python2.5/site-packages/ /path/to/acme/lib/python2.5/site-packages/ |-- Django-1.0.2_final-py2.5.egg | |-- EGG-INFO | `-- django |-- PyYAML-3.06-py2.5-linux-i686.egg |-- batchadmin -> /path/to/django-batchadmin/batchadmin |-- docutils-0.5-py2.5.egg | |-- EGG-INFO | `-- docutils |-- easy-install.pth |-- ipython-0.9.1-py2.5.egg | |-- EGG-INFO | |-- IPython | `-- share |-- setuptools-0.6c9-py2.5.egg | |-- EGG-INFO | |-- easy_install.py | |-- easy_install.pyc | |-- pkg_resources.py | |-- pkg_resources.pyc | |-- setuptools | |-- site.py | `-- site.pyc |-- setuptools.pth `-- zc.buildout-1.1.1-py2.5.egg |-- EGG-INFO |-- README.txt `-- zc END --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---