Home > Back-end >  Customize django behavior on requests from mobile app and any sort of web browser
Customize django behavior on requests from mobile app and any sort of web browser

Time:05-23

Good day,

So I have made a mobile Android/IOS app that communicates with django backend through the http requests. As you understand the backend is hosted on some https://www.example.com domain...
However, in case a user accesses that domain or any extensions (/home, /profile and etc..) from any web browser from any platform, I want to display just a plain page (maybe the name of the app). How can I do so?

Thanks

CodePudding user response:

If you don't want to add new middleware you can add this in your base.html template. Other way would be to write separate middleware in which you check user_agent and redirect to specific page containing your app name

{% if request.user_agent.is_mobile %}
    NAME OF YOUR APP
{% else %}
    Normal page
{% endif %}
  • Related