Posts

Showing posts from 2017

Horrible Things I Regret Doing With Python Part One

Runtime Copy Paste With Global Variable Replacement. "Could you make InlineAdmin in Django paginatable Joe?" Guido asked.  I googled a while before regurgitating a Stackoverflow answer into Guido's lap. "Oh cool, but we have multiple InlineAdmins , can you make it paginate for all of them?" "Sure" I replied, "That'll just be a change to the admin class and some templates" ... Time passes I had quickly changed the 'p' variable so it was dynamically determined by the model name assigned to the InlineAdmin class by adding a page_param property. The only problem was I that needed django's paginator_number template tag to take into account these new page variables as well. from django.contrib.admin.views.main import ( ALL_VAR, ORDER_VAR, PAGE_VAR, SEARCH_VAR, ) ... @register.simple_tag def paginator_number (cl, i): """ Generates an individual page index link in a paginated list.