django-amp-tools ( amp_tools ) provides a simple way to work with Accelerated mobile pages (AMP) in django and gives you tools at your hand to render some different templates to deliver an AMP version of your site to the user.
The initial idea, which has guided the development of this application from django-mobile app, is to keep your views exactly the same but to transparently interchange the templates used to render a response.
This is done in two steps:
- A middleware determines the client's preference to view your site. E.g. if he wants to use the AMP or the standart version.
- The template loader takes then care of choosing the correct templates based on the GET param detected in the middleware.
django-amp-tools depends on django's sites framework. So
before you try to use
django-amp-tools make sure that the sites framework
is enabled and working.
django-amp-toolswith your favourite python tool, e.g. with
pip install django-amp-tools.
INSTALLED_APPSsetting in the
amp_tools.middleware.AMPDetectionMiddlewareto end of your
amp_tools.loader.Loaderas first item to your
Documentation is available online, or in the doc directory of the project.
The source code for this app is hosted at https://github.com/shtalinberg/django-amp-tools.
Pull requests are welcome. See <http://django-amp-tools.readthedocs.io/en/latest/contributing.html>`_.