jython.txt 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. _howto-jython:
  2. ========================
  3. Running Django on Jython
  4. ========================
  5. .. index:: Jython, Java, JVM
  6. Jython_ is an implementation of Python that runs on the Java platform (JVM).
  7. Django runs cleanly on Jython version 2.5 or later, which means you can deploy
  8. Django on any Java platform.
  9. This document will get you up and running with Django on top of Jython.
  10. .. _jython: http://www.jython.org/
  11. Installing Jython
  12. =================
  13. Django works with Jython versions 2.5 and higher.
  14. .. warning::
  15. As of the writing of this document, a version of Jython compatible with
  16. Django has not yet been released. The forthcoming 2.5a2+ release will be be
  17. the first in which Django will work out of the box.
  18. In the meantime, you'll need to use the latest development version of Jython
  19. obtained from Jython's SVN repository.
  20. Download Jython at http://www.jython.org/.
  21. Creating a servlet container
  22. ============================
  23. If you just want to experiment with Django, skip ahead to the next section;
  24. Django includes a lightweight Web server you can use for testing, so you won't
  25. need to set up anything else until you're ready to deploy Django in production.
  26. If you want to use Django on a production site, use a Java servlet container,
  27. such as `Apache Tomcat`_. Full JavaEE applications servers such as `GlassFish`_
  28. or `JBoss`_ are also OK, if you need the extra features they include.
  29. .. _`Apache Tomcat`: http://tomcat.apache.org/
  30. .. _GlassFish: https://glassfish.dev.java.net/
  31. .. _JBoss: http://www.jboss.org/
  32. Installing Django
  33. =================
  34. The next step is to install Django itself. This is exactly the same as
  35. installing Django on standard Python, so see
  36. :ref:`removing-old-versions-of-django` and :ref:`install-django-code` for
  37. instructions.
  38. Installing Jython platform support libraries
  39. ============================================
  40. The `django-jython`_ project contains database backends and management commands
  41. for Django/Jython development. Note that the builtin Django backends won't work
  42. on top of Jython.
  43. .. _`django-jython`: http://code.google.com/p/django-jython/
  44. To install it, follow the `installation instructions`_ detailed on the project
  45. website. Also, read the `database backends`_ documentation there.
  46. .. _`installation instructions`: http://code.google.com/p/django-jython/wiki/Install
  47. .. _`database backends`: http://code.google.com/p/django-jython/wiki/DatabaseBackends
  48. Differences with Django on Jython
  49. =================================
  50. .. index:: JYTHONPATH
  51. At this point, Django on Jython should behave nearly identically to Django
  52. running on standard Python. However, are a few differences to keep in mind:
  53. * Remember to use the ``jython`` command instead of ``python``. The
  54. documentation uses ``python`` for consistancy, but if you're using Jython
  55. you'll want to mentally replace ``python`` with ``jython`` every time it
  56. occurs.
  57. * Similarly, you'll need to use the ``JYTHONPATH`` environment variable
  58. instead of ``PYTHONPATH``.