Skip to main content

Django Middlware to detect Dartium web browser.

Project description

django-dartium provides for a simple way to detect the Dartium web browser and make it easy to serve Dart sources instead of compiled JavaScript during development.


Python 3 and Django are the only requirements:

  1. Install django-dartium with your favorite python tool, e.g. pip install django-dartium.

  2. Add django_dartium to your INSTALLED_APPS setting.

  3. Add django_dartium.middleware.DartiumDetectionMiddleware to your MIDDLEWARE_CLASSES setting.

  4. Add two named mappings to STATICFILES_DIRS, one named dart/build which points to the build location of the JavaScript output and the other is dart/src which points to the web directory containing your original Dart source. If you created your Django project by running django-admin startproject your_project and placed your Dart sources in your_project/your_project/dart directory, then you would have the following STATICFILES_DIRS:

      ('dart/build', 'your_project/dart/build/web'),
      ('dart/src', 'your_project/dart/web'),


Load the dartium tag library into your Django template, call the webcomponents tag to load the necessary polyfills and then add a reference to your Dart code via the dart tag.

A good setup would be to have the following in your base.html:

{% load dartium %}
  {% block content %}
  {% endblock %}

  {% webcomponents 'lite' %}
  {% block script %}
  {% endblock %}

Then in each of your pages where you want to use Dart some Dart script you can add:

{% load dartium %}
{% block content %}
  ... page content ...
{% endblock %}
{% block script %}
  {% dart "your_script.dart" %}
{% endblock %}

The end result will be that if you browse to this page with Dartium you will get served your original Dart source but if you are using any other browser you’ll be served your_script.dart.js from the build/web directory.


  • Initial release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-dartium, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django-dartium-0.1.1.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page