문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

Django settings are global. They affect the whole process.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top