On zaterdag 7 april 2018 09:02:52 CEST Samuel Muiruri wrote:
> Hey guys,
> Think this would be a neat feature to add to django.
>
> {% if request.connection %}
> #if there's a connection to the internet returns True, by default tries
> to connect to google
> {% else %}
> #could for example load local js/css files instead of from cdn
> {% endif %}
Neigh. Think about what you're proposing here:
So on the incoming browser request object you instantiate a connection from
your server to some site. This by no means ensures that the browser can
connect to that service.
There's also no way to "tell the browser to check availability to that site",
because once the request object is created in Django the browser has already
sent the request - it's not two-way communication.
This should be handled in javascript and Django cannot do anything for you
here as it's not part of the problem.
--
Melvyn Sopacua