python - More elegant way to ignore static urls in Middleware in Django? -
middleware-wizards,
i wondering if there more elegant way find out whether request serves 1 of custom view methods or rather static content etc. instead?
class mymiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): if view_func.__name__ != 'serve': # here return none
if serving static files via static_url can check request.path
. (process_request)
def process_request(request): if request.path.startswith(settings.static_url): # here
anyway that's applicable during development cause apache or nginx or cdn serving static files , requests never hit django app.
Comments
Post a Comment