Django sites - different urls.py for two sites

I support Django webapp for my client. We built it in Django and for computer users, this is great. Now we want to serve mobile device users.

Besides the template switcher, we also need things to be different. The application will have views that work in different ways, but itโ€™s also necessary to simplify the structure of the URL.

I understand that I'm going to ask if the DRY ethos violates, but is there a good way to split urls.pyso that half of them are for ourdomain.comand the other half for m.ourdomain.com? If I can do this, I can add mobile_views.pyand write new views.

Django sites are included in the project, but I'm glad to use a hard-coded request.domain.startswith('m.')style. It seems like it might be better, but I don't know how to get the request from the URL file.

+5
source share
1 answer

Use middleware to discover access to another site and set request.urlconfto another urlconf that you want to use.

+6
source

All Articles