Question

I set a variable MAX_REQUEST = 100 in settings.py

I write a middleware which may lower this value for request origining from a proxy ip address by the following code:

settings.MAX_REQUEST = 10

However, looks like the above modification affects all legitimate users.

Is it normal?

Was it helpful?

Solution

Yes. settings is a module referenced all over by Django (and probably your code too). Modifying any variable in settings is like modifying a global variable and alters the behaviour of your whole web app.

OTHER TIPS

Django settings are global. They affect the whole process.

If you want 'per user' variables, I suggest you look at How to use sessions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top