Questions tagged [django-middleware]

Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “plugin” system for globally altering Django’s input and/or output.

Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “plugin” system for globally altering Django’s input and/or output. Each middleware component is responsible for doing some specific function.

Django ships with some built-in middleware you can use right out of the box; they’re documented in the built-in middleware reference.

455 questions
0
votes
2 answers

Using Django middleware to check GET variables in current page URL

Can I use a middleware to preserve several user selected choices in between page requests? I have several values, namely vehicle year, make, model, series, style, color, and transmission. I want to have the user being able to select a choice…
Stephen
  • 5,959
  • 10
  • 33
  • 43
0
votes
2 answers

Updating a hit counter when an image is accessed in Django

I am working on doing some simple analytics on a Django webstite (v1.4.1). Seeing as this data will be gathered on pretty much every server request, I figured the right way to do this would be with a piece of custom middleware. One important metric…
dirtshell
  • 161
  • 2
  • 12
0
votes
2 answers

Django: django-secretballot MIDDLEWARE

When adding 'secretballot.middleware.SecretBallotMiddleware' to MIDDLEWARE_CLASSES I keep getting the following error: Exception Type: NotImplementedError Exception Location: .../django_secretballot-0.2.3-py2.7.egg/secretballot/middleware.py in…
alxmrph
  • 99
  • 1
  • 9
0
votes
2 answers

ImproperlyConfigured: Error importing middleware treeio.core.middleware.user

I got this error: [Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88] mod_wsgi (pid=19481): Exception occurred processing WSGI script '/home/projects/treeio/treeio.wsgi'. [Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88] Traceback (most…
Darkering
  • 35
  • 7
0
votes
0 answers

Django exceptions, select what to report to admins

Is there any way to "tell" Django when to send emails to admins and when not? For instance, I'd like to not send an email when a DatabaseError exception is thrown. I thought of creating a middleware and return None if exception was of type…
carl-lopez
  • 584
  • 5
  • 12
0
votes
1 answer

When does Django's Middleware framework hook the request?

Does the Middleware framework hook the request object before it is sent to the urlconf? Also, does this hook happen after it goes through WSGIHandler? So, just in respect to these three "layers", is it the order in which request is…
user1563285
0
votes
1 answer

Setting up local django environment for multiple domains

I'm trying to set up a Django application that will accept multiple subdomain URLs. I'd like to test this locally. Since I can't nail this first step of passing in a url that has a subdomain, I can't get to the second part (figuring out if the…
Brian Dant
  • 4,029
  • 6
  • 33
  • 47
0
votes
1 answer

Django custom middleware messes session middleware

I'm trying to diagnose the error in my custom middleware somehow brings down my session middleware. The custom middleware is a simple app which deletes old files in some folders. class DeleteMediaMiddleware(object): time_limit = 100. def…
TheMeaningfulEngineer
  • 15,679
  • 27
  • 85
  • 143
0
votes
1 answer

How do I inherit plugins to child pages without breaking links in Django-CMS?

I'm making a multilingual Django-CMS site. I have a page that has some content in it that links to a child page, in such a way to keep that link stays visible. This means someone can click the link repeatedly. The link resides in a plugin that is in…
0
votes
1 answer

How to register a decorator or add a middleware to a third party view function?

I use django-allauth for account management including signup. The built-in url in allauth app for signup is http://example.com/accounts/signup/. I need to show a Terms & Conditions page before going to signup page. Now, any one can type this URL…
Babu
  • 2,548
  • 3
  • 30
  • 47
0
votes
1 answer

Why is my SSL middleware misbehaving?

I'm using middleware to force certain pages to be served over HTTPS: class SSLRedirect: def __init__(self): self.enabled = getattr(settings, 'SSL_ENABLED') def process_view(self, request, view_func, view_args, view_kwargs): if SSL in…
fredley
  • 32,953
  • 42
  • 145
  • 236
0
votes
1 answer

Why does my redirect middleware fail?

I have a middleware that redirects mobile users to a mobile site, but I want to direct them to the the full site if the url is /property/. The mobile redirect is working, but /property/ is not being excluded. Here is the current…
tjoenz
  • 699
  • 5
  • 14
  • 39
0
votes
3 answers

Django middleware is ImproperlyConfigured?

For some reason, I am getting an ImproperlyConfigured error on account of custom middleware. [Wed Nov 07 20:47:07 2012] [error] [client 158.130.107.158] File does not exist: /home/davidxu/public_html/favicon.ico [Wed Nov 07 20:47:09 2012] [error]…
Ceasar
  • 22,185
  • 15
  • 64
  • 83
0
votes
1 answer

getting the template name and the time it takes to render in a middleware based on a url

I want to write a middleware that would tell me the name of the template being rendered and the time it took, for the database queries for that particular view. Django Debug Toolbar does the same, but due to custom request and response object…
user1629366
  • 1,931
  • 5
  • 20
  • 30
0
votes
1 answer

What is a django middleware equivalent in ASP MVC?

Basically, I want to inject some data into ViewData/ViewBag for every single request.
Kugel
  • 19,354
  • 16
  • 71
  • 103
1 2 3
30
31