test.utils.setup_test_environment()

setup_test_environment() [source] Performs global pre-test setup, such as installing instrumentation for the template rendering system and setting up the dummy email outbox.

test.utils.teardown_test_environment()

teardown_test_environment() [source] Performs global post-test teardown, such as removing instrumentation from the template system and restoring normal email services.

Testing GeoDjango apps

Included in this documentation are some additional notes and settings for PostGIS users. PostGIS Settings Note The settings below have sensible defaults, and shouldn’t require manual setting. POSTGIS_VERSION When GeoDjango’s spatial backend initializes on PostGIS, it has to perform an SQL query to determine the version in order to figure out what features are available. Advanced users wishing to prevent this additional query may set the version manually using a 3-tuple of integers specifying

Testing in Django

Automated testing is an extremely useful bug-killing tool for the modern Web developer. You can use a collection of tests – a test suite – to solve, or avoid, a number of problems: When you’re writing new code, you can use tests to validate your code works as expected. When you’re refactoring or modifying old code, you can use tests to ensure your changes haven’t affected your application’s behavior unexpectedly. Testing a Web application is a complex task, because a Web application is made o

The Django admin documentation generator

Django’s admindocs app pulls documentation from the docstrings of models, views, template tags, and template filters for any app in INSTALLED_APPS and makes that documentation available from the Django admin. Overview To activate the admindocs, you will need to do the following: Add django.contrib.admindocs to your INSTALLED_APPS. Add url(r'^admin/doc/', include('django.contrib.admindocs.urls')) to your urlpatterns. Make sure it’s included before the r'^admin/' entry, so that requests to /admin

The Django template language

This document explains the language syntax of the Django template system. If you’re looking for a more technical perspective on how it works and how to extend it, see The Django template language: for Python programmers. Django’s template language is designed to strike a balance between power and ease. It’s designed to feel comfortable to those used to working with HTML. If you have any exposure to other text-based template languages, such as Smarty or Jinja2, you should feel right at home with

Time zones

Overview When support for time zones is enabled, Django stores datetime information in UTC in the database, uses time-zone-aware datetime objects internally, and translates them to the end user’s time zone in templates and forms. This is handy if your users live in more than one time zone and you want to display datetime information according to each user’s wall clock. Even if your website is available in only one time zone, it’s still good practice to store data in UTC in your database. The ma

Unicode data

Django natively supports Unicode data everywhere. Providing your database can somehow store the data, you can safely pass around Unicode strings to templates, models and the database. This document tells you what you need to know if you’re writing applications that use data or templates that are encoded in something other than ASCII. Creating the database Make sure your database is configured to be able to store arbitrary string data. Normally, this means giving it an encoding of UTF-8 or UTF-1

Upgrading Django to a newer version

While it can be a complex process at times, upgrading to the latest Django version has several benefits: New features and improvements are added. Bugs are fixed. Older version of Django will eventually no longer receive security updates. (see Supported versions). Upgrading as each new Django release is available makes future upgrades less painful by keeping your code base up to date. Here are some things to consider to help make your upgrade process as smooth as possible. Required Reading If

Upgrading templates to Django 1.8

Django’s template system was overhauled in Django 1.8 when it gained support for multiple template engines. This document complements the release notes with detailed upgrade instructions on some topics. The TEMPLATES settings A new setting was introduced in Django 1.8: TEMPLATES. All existing template-related settings were deprecated. During the deprecation period, Django will create a backwards-compatible TEMPLATES based on the TEMPLATE_* settings if you don’t define it yourself. Here’s how to