Re: Application specific middleware support

2019-07-07 Thread Aymeric Augustin
Oops! Scratch that, let's try again... So Django doesn't create a relationship incoming HTTP requests and applications. You could try to create such a relationship, based on where URLconfs or views are defined, but you'll quickly discover tons of edge cases — starting with decorators — that mak

Re: Application specific middleware support

2019-07-07 Thread Adam Johnson
Aymeric, are you sure about that? I can't find the code, and the docs for current_app say it's noto set by Django itself: https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.current_app Also middleware can't reliably make use of routing information except in process

Re: Application specific middleware support

2019-07-07 Thread Aymeric Augustin
Hello Kapil, When you talk of a "URL served by an app", I suppose you're referring to URL namespaces, which provide a request.currrent_app attribute associating an HTTP request to an app. As far as I know, this is the only association of a request and an app that Django defines. Django's docum

Re: Application specific middleware support

2019-07-07 Thread Adam Johnson
Hi Kapil The main reason I believe is because URL's are project global, rather than per app. Yes the root urlconf can include URL's kept within apps, but because it's a recursive data structure this isn't so easy. For your use case I'd suggest either: - Using class based views, creating a sub