<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Running Django on Jython — Django 1.8.19 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.8.19', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="top" title="Django 1.8.19 documentation" href="../contents.html" /> <link rel="up" title="“How-to” guides" href="index.html" /> <link rel="next" title="Integrating Django with a legacy database" href="legacy-databases.html" /> <link rel="prev" title="Providing initial data for models" href="initial-data.html" /> <script type="text/javascript" src="../templatebuiltins.js"></script> <script type="text/javascript"> (function($) { if (!django_template_builtins) { // templatebuiltins.js missing, do nothing. return; } $(document).ready(function() { // Hyperlink Django template tags and filters var base = "../ref/templates/builtins.html"; if (base == "#") { // Special case for builtins.html itself base = ""; } // Tags are keywords, class '.k' $("div.highlight\\-html\\+django span.k").each(function(i, elem) { var tagname = $(elem).text(); if ($.inArray(tagname, django_template_builtins.ttags) != -1) { var fragment = tagname.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>"); } }); // Filters are functions, class '.nf' $("div.highlight\\-html\\+django span.nf").each(function(i, elem) { var filtername = $(elem).text(); if ($.inArray(filtername, django_template_builtins.tfilters) != -1) { var fragment = filtername.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>"); } }); }); })(jQuery); </script> </head> <body role="document"> <div class="document"> <div id="custom-doc" class="yui-t6"> <div id="hd"> <h1><a href="../index.html">Django 1.8.19 documentation</a></h1> <div id="global-nav"> <a title="Home page" href="../index.html">Home</a> | <a title="Table of contents" href="../contents.html">Table of contents</a> | <a title="Global index" href="../genindex.html">Index</a> | <a title="Module index" href="../py-modindex.html">Modules</a> </div> <div class="nav"> « <a href="initial-data.html" title="Providing initial data for models">previous</a> | <a href="index.html" title="&#8220;How-to&#8221; guides" accesskey="U">up</a> | <a href="legacy-databases.html" title="Integrating Django with a legacy database">next</a> »</div> </div> <div id="bd"> <div id="yui-main"> <div class="yui-b"> <div class="yui-g" id="howto-jython"> <div class="section" id="s-running-django-on-jython"> <span id="running-django-on-jython"></span><h1>Running Django on Jython<a class="headerlink" href="#running-django-on-jython" title="Permalink to this headline">¶</a></h1> <p id="index-0"><a class="reference external" href="http://www.jython.org/">Jython</a> is an implementation of Python that runs on the Java platform (JVM). This document will get you up and running with Django on top of Jython.</p> <div class="section" id="s-installing-jython"> <span id="installing-jython"></span><h2>Installing Jython<a class="headerlink" href="#installing-jython" title="Permalink to this headline">¶</a></h2> <p>Django works with Jython versions 2.7b2 and higher. See the <a class="reference external" href="http://www.jython.org/">Jython</a> Web site for download and installation instructions.</p> </div> <div class="section" id="s-creating-a-servlet-container"> <span id="creating-a-servlet-container"></span><h2>Creating a servlet container<a class="headerlink" href="#creating-a-servlet-container" title="Permalink to this headline">¶</a></h2> <p>If you just want to experiment with Django, skip ahead to the next section; Django includes a lightweight Web server you can use for testing, so you won’t need to set up anything else until you’re ready to deploy Django in production.</p> <p>If you want to use Django on a production site, use a Java servlet container, such as <a class="reference external" href="http://tomcat.apache.org/">Apache Tomcat</a>. Full JavaEE applications servers such as <a class="reference external" href="https://glassfish.java.net/">GlassFish</a> or <a class="reference external" href="http://www.jboss.org/">JBoss</a> are also OK, if you need the extra features they include.</p> </div> <div class="section" id="s-installing-django"> <span id="installing-django"></span><h2>Installing Django<a class="headerlink" href="#installing-django" title="Permalink to this headline">¶</a></h2> <p>The next step is to install Django itself. This is exactly the same as installing Django on standard Python, so see <a class="reference internal" href="../topics/install.html#removing-old-versions-of-django"><span class="std std-ref">Remove any old versions of Django</span></a> and <a class="reference internal" href="../topics/install.html#install-django-code"><span class="std std-ref">Install the Django code</span></a> for instructions.</p> </div> <div class="section" id="s-installing-jython-platform-support-libraries"> <span id="installing-jython-platform-support-libraries"></span><h2>Installing Jython platform support libraries<a class="headerlink" href="#installing-jython-platform-support-libraries" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference external" href="http://code.google.com/p/django-jython/">django-jython</a> project contains database backends and management commands for Django/Jython development. Note that the builtin Django backends won’t work on top of Jython.</p> <p>To install it, follow the <a class="reference external" href="https://pythonhosted.org/django-jython/quickstart.html#install">installation instructions</a> detailed on the project Web site. Also, read the <a class="reference external" href="https://pythonhosted.org/django-jython/database-backends.html">database backends</a> documentation there.</p> </div> <div class="section" id="s-differences-with-django-on-jython"> <span id="differences-with-django-on-jython"></span><h2>Differences with Django on Jython<a class="headerlink" href="#differences-with-django-on-jython" title="Permalink to this headline">¶</a></h2> <p id="index-1">At this point, Django on Jython should behave nearly identically to Django running on standard Python. However, are a few differences to keep in mind:</p> <ul class="simple"> <li>Remember to use the <code class="docutils literal"><span class="pre">jython</span></code> command instead of <code class="docutils literal"><span class="pre">python</span></code>. The documentation uses <code class="docutils literal"><span class="pre">python</span></code> for consistency, but if you’re using Jython you’ll want to mentally replace <code class="docutils literal"><span class="pre">python</span></code> with <code class="docutils literal"><span class="pre">jython</span></code> every time it occurs.</li> <li>Similarly, you’ll need to use the <code class="docutils literal"><span class="pre">JYTHONPATH</span></code> environment variable instead of <code class="docutils literal"><span class="pre">PYTHONPATH</span></code>.</li> <li>Any part of Django that requires <a class="reference external" href="http://pillow.readthedocs.org/en/latest/">Pillow</a> will not work.</li> </ul> </div> </div> </div> </div> </div> <div class="yui-b" id="sidebar"> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Running Django on Jython</a><ul> <li><a class="reference internal" href="#installing-jython">Installing Jython</a></li> <li><a class="reference internal" href="#creating-a-servlet-container">Creating a servlet container</a></li> <li><a class="reference internal" href="#installing-django">Installing Django</a></li> <li><a class="reference internal" href="#installing-jython-platform-support-libraries">Installing Jython platform support libraries</a></li> <li><a class="reference internal" href="#differences-with-django-on-jython">Differences with Django on Jython</a></li> </ul> </li> </ul> <h3>Browse</h3> <ul> <li>Prev: <a href="initial-data.html">Providing initial data for models</a></li> <li>Next: <a href="legacy-databases.html">Integrating Django with a legacy database</a></li> </ul> <h3>You are here:</h3> <ul> <li> <a href="../index.html">Django 1.8.19 documentation</a> <ul><li><a href="index.html">“How-to” guides</a> <ul><li>Running Django on Jython</li></ul> </li></ul> </li> </ul> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/howto/jython.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <div><input type="text" name="q" /></div> <div><input type="submit" value="Go" /></div> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <h3>Last update:</h3> <p class="topless">Feb 12, 2019</p> </div> </div> <div id="ft"> <div class="nav"> « <a href="initial-data.html" title="Providing initial data for models">previous</a> | <a href="index.html" title="&#8220;How-to&#8221; guides" accesskey="U">up</a> | <a href="legacy-databases.html" title="Integrating Django with a legacy database">next</a> »</div> </div> </div> <div class="clearer"></div> </div> </body> </html>