This patch makes bookmarklets work for people without static IPs on their development workstations. All the nice bookmarkletts django provides now work not only ffor uders coming from INTERNAL_IPS but from all users where is_staff=True. --md@hudora.de Index: django/core/xheaders.py =================================================================== --- django/core/xheaders.py (revision 3764) +++ django/core/xheaders.py (working copy) @@ -13,9 +13,11 @@ """ Adds the "X-Object-Type" and "X-Object-Id" headers to the given HttpResponse according to the given model and object_id -- but only if the - given HttpRequest object has an IP address within the INTERNAL_IPS setting. + given HttpRequest object has an IP address within the INTERNAL_IPS setting + or if the request is from a logged in staff user. """ from django.conf import settings - if request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS: + if (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS) \ + or (request.user.is_authenticated() and request.user.is_staff): response['X-Object-Type'] = "%s.%s" % (model._meta.app_label, model._meta.object_name.lower()) response['X-Object-Id'] = str(object_id) Index: django/middleware/doc.py =================================================================== --- django/middleware/doc.py (revision 3764) +++ django/middleware/doc.py (working copy) @@ -7,11 +7,14 @@ """ def process_view(self, request, view_func, view_args, view_kwargs): """ - If the request method is HEAD and the IP is internal, quickly return - with an x-header indicating the view function. This is used by the - documentation module to lookup the view function for an arbitrary page. + If the request method is HEAD and the IP is internal or the user is + a logged in staff user, quickly return with an x-header indicating + the view function. This is used by the documentation module to + lookup the view function for an arbitrary page. """ - if request.method == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS: + if request.method == 'HEAD' \ + and ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS) \ + or (request.user.is_authenticated() and request.user.is_staff)): response = http.HttpResponse() response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__) return response