File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ from pyconbalkan .conference .models import Conference
2+
3+
4+ class ConferenceSelectionMiddleware :
5+ def __init__ (self , get_response ):
6+ self .get_response = get_response
7+
8+ def __call__ (self , request ):
9+ # Code to be executed for each request before
10+ # the view (and later middleware) are called.
11+
12+ # Domain format : 2019.pyconbalkan.com
13+ domain = request .META ['HTTP_HOST' ]
14+ conference = Conference .objects .get (year = domain .split ('.' )[0 ])
15+ # Every request will have an atribute `conference` in it
16+ # `conference` is the conference.models.Conference object for the
17+ # respective year fetched from it's domain
18+ request .conference = conference
19+ response = self .get_response (request )
20+ return response
You can’t perform that action at this time.
0 commit comments