Do not use appname as templatetags module
This is the second time I created same error writing templatetags, so it is about time to document it.
This is the bad layout for poll app.
polls/
__init__.py
models.py
templatetags/
__init__.py
polls.py
views.py
Instead of polls.py it should be polls_tags.py or something other different from appname.
Whats going on? polls.py would define polls module and it would not be possible to import other modules from original polls application.
For example the code bellow would throw ImportError: No module named models
#polls.py from django import template from polls.models import Question register = template.Library()
Announcing FeinCMS Extensions
Django time widget with custom time shortcuts
This small javascript snippet replaces standard django clock shortcuts Midnight, Noon, Now & 6am with various time increments .

$(window).load(function() {
$('.timelist').each(function(num, el) {
time_format = get_format('TIME_INPUT_FORMATS')[0];
$(el).html('');
for (i=8; i<20; i++) {
var time = new Date(1970,1,1,i,0,0);
lnk = "javascript:DateTimeShortcuts.handleClockQuicklink(" + num +
", '" + time.strftime(time_format) + "');"
$(el).append('<li><a href="'lnk'">' + time.strftime('%H:%M') + '</a></li>');
}
});
});
This snippet use JQuery which is available with Django 1.2. (dev at time of writing)
Also, javascript should be loaded after DateTimeShortcuts.js but unfortunately I didn’t find a better way to achive this but to add in modified base admin site templates/admin/base_site.html. If you have any suggestion for improvement, let me know in comments.
Django-simpleadmindoc
I started this project as I needed to deliver help and documentation for django-admin on client website and admindocs seems more oriented to developers than to users.
http://github.com/bmihelac/django-simpleadmindoc

Django set language for admin
If you want to explicitly set language for django admin section use this middleware:
from django.conf import settings
class AdminLocaleURLMiddleware:
def process_request(self, request):
if request.path.startswith('/admin'):
request.LANG = getattr(settings, 'ADMIN_LANGUAGE_CODE', settings.LANGUAGE_CODE)
translation.activate(request.LANG)
request.LANGUAGE_CODE = request.LANG
Then put somewhere in settings.py:
ADMIN_LANGUAGE_CODE=’it’
and add middleware:
MIDDLEWARE_CLASSES = (
...
'utils.multilang.middleware.AdminLocaleURLMiddleware',
....
I am Bojan Mihelac and this blog is dedicated to share code, thoughts, tools and advices I came up with while working at