March 23, 2012

Welcome to Django 1.4!

These release notes cover the new features, as well as some backwards incompatible changes you’ll want to be aware of when upgrading from Django 1.3 or older versions. We’ve also dropped some features, which are detailed in our deprecation plan, and we’ve begun the deprecation process for some features.

Wherever possible we try to introduce new features in a backwards-compatible manner per our API stability policy policy. However, as with previous releases, Django 1.4 ships with some minor backwards incompatible changes ; people upgrading from previous versions of Django should read that list carefully.

If you’re upgrading an existing project to Django 1.4, switching to the timezone aware mode may take some care: the new mode disallows some rather sloppy behavior that used to be accepted. We encourage anyone who’s upgrading to check out the timezone migration guide and the timezone FAQ for useful pointers.

The biggest new feature in Django 1.4 is support for time zones when handling date/times. When enabled, this Django will store date/times in UTC, use timezone-aware objects internally, and translate them to users’ local timezones for display.

Django does not support Python 3.x at this time. At some point before the release of Django 1.4, we plan to publish a document outlining our full timeline for deprecating Python 2.x and moving to Python 3.x.

This change should affect only a small number of Django users, as most operating-system vendors today are shipping Python 2.5 or newer as their default version. If you’re still using Python 2.4, however, you’ll need to stick to Django 1.3 until you can upgrade. Per our support policy , Django 1.3 will continue to receive security support until the release of Django 1.5.

Django 1.4 has dropped support for Python 2.4. Python 2.5 is now the minimum required Python version. Django is tested and supported on Python 2.5, 2.6 and 2.7.

A new django.test.SimpleTestCase subclass of unittest.TestCase that’s lighter than django.test.TestCase and company. It can be useful in tests that don’t need to hit a database. See Hierarchy of Django unit testing classes .

The sitemaps framework can now handle HTTPS links using the new Sitemap.protocol class attribute.

It’s now possible to pass initial values to the model forms that are part of both model formsets and inline model formsets as returned from factory functions modelformset_factory and inlineformset_factory respectively just like with regular formsets. However, initial values only apply to extra forms, i.e. those which are not bound to an existing model instance.

The MySQL database backend can now make use of the savepoint feature implemented by MySQL version 5.0.3 or newer with the InnoDB storage engine.

The admin login page will add a password reset link if you include a URL with the name 'admin_password_reset' in your urls.py, so plugging in the built-in password reset mechanism and making it available is now much easier. For details, see Adding a password reset feature .

The distinct() QuerySet method now accepts an optional list of model field names. If specified, then the DISTINCT statement is limited to these fields. This is only supported in PostgreSQL.

Changed the locmem cache backend to use pickle.HIGHEST_PROTOCOL for better compatibility with the other cache backends.

This should make it easier to read when debugging interaction with client-side JavaScript.

Like its HTML counterpart, it contains a collection of different pieces of information about the state of the application.

A new, plain-text, version of the HTTP 500 status code internal error page served when DEBUG is True is now sent to the client when Django detects that the request has originated in JavaScript code. ( is_ajax() is used for this.)

If your Django app is behind a proxy, you might find the new SECURE_PROXY_SSL_HEADER setting useful. It solves the problem of your proxy “eating” the fact that a request came in via HTTPS. But only use this setting if you know what you’re doing.

The trans template tag now takes an optional as argument to be able to retrieve a translation string without displaying it but setting a template context variable instead.

The base classes in django.test now have some helpers to compare HTML without tripping over irrelevant differences in whitespace, argument quoting/ordering and closing of self-closing tags. You can either compare HTML directly with the new assertHTMLEqual() and assertHTMLNotEqual() assertions, or use the html=True flag with assertContains() and assertNotContains() to test whether the client’s response contains a given HTML fragment. See the assertions documentation for more.

Django 1.4 can now better handle IPv6 addresses with the new GenericIPAddressField model field, GenericIPAddressField form field and the validators validate_ipv46_address and validate_ipv6_address .

You can override or customize the default filtering by writing a custom filter . For more information see the docs on Filtering error reports .

All POST parameters are now systematically filtered out of error reports for certain views ( login , password_reset_confirm , password_change and add_view in django.contrib.auth.views , as well as user_change_password in the admin app) to prevent the leaking of sensitive information such as user passwords.

We added two function decorators, sensitive_variables() and sensitive_post_parameters() , to allow designating the local variables and POST parameters that may contain sensitive information and should be filtered out of error reports.

We’ve made various improvements to our CSRF features, including the ensure_csrf_cookie() decorator, which can help with AJAX-heavy sites; protection for PUT and DELETE requests; and the CSRF_COOKIE_SECURE and CSRF_COOKIE_PATH settings, which can improve the security and usefulness of CSRF protection. See the CSRF docs for more information.

We’ve added a middleware to provide easy protection against clickjacking using the X-Frame-Options header. It’s not enabled by default for backwards compatibility reasons, but you’ll almost certainly want to enable it to help plug that security hole for browsers that support the header.

The staticfiles contrib app now has a django.contrib.staticfiles.storage.CachedStaticFilesStorage backend that caches the files it saves (when running the collectstatic management command) by appending the MD5 hash of the file’s content to the filename. For example, the file css/styles.css would also be saved as css/styles.55e7cbb9ba48.css

The staticfiles contrib app has a new static template tag to refer to files saved with the STATICFILES_STORAGE storage backend. It uses the storage backend’s url method and therefore supports advanced features such as serving files from a cloud service .

This new filter truncates a string to be no longer than the specified number of characters. Truncated strings end with a translatable ellipsis sequence (“…”). See the documentation for truncatechars for more details.

In Django 1.4, exceptions are no longer wrapped. Instead, the original exception is annotated with the source information. This means that catching exceptions from template rendering is now consistent regardless of the value of TEMPLATE_DEBUG , and there’s no need to catch and unwrap TemplateSyntaxError in order to catch other errors.

In previous versions of Django, whenever the TEMPLATE_DEBUG setting was True , any exception raised during template rendering (even exceptions unrelated to template syntax) were wrapped in TemplateSyntaxError and re-raised. This was done in order to provide detailed template source location information in the debug 500 page.

Then, in the template, any number of arguments may be passed to the template tag. For example:

The simple_tag , inclusion_tag and newly introduced assignment_tag template helper functions may now accept any number of positional or keyword arguments. For example:

Two new attributes, pk_url_kwarg and slug_url_kwarg , have been added to SingleObjectMixin to enable the customization of URLconf keyword arguments used for single object generic views.

The contextual translation support introduced in Django 1.3 via the pgettext function has been extended to the trans and blocktrans template tags using the new context keyword.

Django can now look for a language prefix in the URLpattern when using the new i18n_patterns() helper function. It’s also now possible to define translatable URL patterns using django.utils.translation.ugettext_lazy() . See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns.

A lazily evaluated version of reverse() was added to allow using URL reversals before the project’s URLconf gets loaded.

Django 1.4 ships with a session-based storage backend and a cookie-based storage backend. The latter uses the tools for cryptographic signing also introduced in Django 1.4 to store the wizard’s state in the user’s cookies.

The previous FormWizard from django.contrib.formtools has been replaced with a new implementation based on the class-based views introduced in Django 1.3. It features a pluggable storage API and doesn’t require the wizard to pass around hidden fields for every previous step.

Session data is signed and validated by the server, but it’s not encrypted. This means a user can view any data stored in the session but cannot change it. Please read the documentation for further clarification before using this backend.

Django 1.4 introduces a cookie-based session backend that uses the tools for cryptographic signing to store the session data in the client’s browser.

Admin inlines now only allow those actions for which the user has permission. For ManyToMany relationships with an auto-created intermediate model (which does not have its own permissions), the change permission for the related model determines if the user has the permission to add, change or delete relationships.

Two other new ModelAdmin methods, get_list_display() and get_list_display_links() enable dynamic customization of fields and links displayed on the admin change list.

We added a save_related() method to ModelAdmin to ease customization of how related objects are saved in the admin.

The admin change list now supports sorting on multiple columns. It respects all elements of the ordering attribute, and sorting on multiple columns by clicking on headers is designed to mimic the behavior of desktop GUIs. We also added a get_ordering() method for specifying the ordering dynamically (i.e., depending on the request).

Prior to Django 1.4, the admin app let you specify change list filters by specifying a field lookup, but it didn’t allow you to create custom filters. This has been rectified with a simple API (previously used internally and known as “FilterSpec”). For more details, see the documentation for list_filter .

We’ve switched the admin and other bundled templates to use the HTML5 doctype. While Django will be careful to maintain compatibility with older browsers, this change means that you can use any HTML5 features you need in admin pages without having to lose HTML validity or override the provided templates to change the doctype.

Django’s auth system ( django.contrib.auth ) stores passwords using a one-way algorithm. Django 1.3 uses the SHA1 algorithm, but increasing processor speeds and theoretical attacks have revealed that SHA1 isn’t as secure as we’d like. Thus, Django 1.4 introduces a new password storage system: by default Django now uses the PBKDF2 algorithm (as recommended by NIST ). You can also easily choose a different algorithm (including the popular bcrypt algorithm). For more details, see How Django stores passwords .

Similar to select_related() but with a different strategy and broader scope, prefetch_related() has been added to QuerySet . This method returns a new QuerySet that will prefetch each of the specified related lookups in a single batch as soon as the query begins to be evaluated. Unlike select_related , it does the joins in Python, not in the database, and supports many-to-many relationships, GenericForeignKey and more. This allows you to fix a very common performance problem in which your code ends up doing O(n) database queries (or worse) if objects on your primary QuerySet each have many related objects that you also need to fetch.

Django makes use of this internally, meaning some operations (such as database setup for test suites) have seen a performance benefit as a result.

This method lets you create multiple objects more efficiently. It can result in significant performance increases if you have many objects.

The built-in development server now supports using an externally-defined WSGI callable, which makes it possible to run runserver with the same WSGI configuration that is used for deployment. The new WSGI_APPLICATION setting lets you configure which WSGI callable runserver uses.

The startproject management command now adds a wsgi.py module to the initial project layout, containing a simple WSGI application that can be used for deploying with WSGI app servers .

You can also now provide a destination directory as the second argument to both startapp and startproject :

For example, Django will use the /path/to/my_project_template directory when you run the following command:

The startapp and startproject management commands now have a --template option for specifying a path or URL to a custom app or project template.

Django 1.4 supports integration with in-browser testing frameworks like Selenium . The new django.test.LiveServerTestCase base class lets you test the interactions between your site’s front and back ends more comprehensively. See the documentation for more details and concrete examples.

Time zone support is enabled by default in new projects created with startproject . If you want to use this feature in an existing project, read the migration guide . If you encounter problems, there’s a helpful FAQ .

In Django 1.4, you can now switch Django into a more correct, time-zone aware mode. In this mode, Django stores date and time 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. Reasons for using this feature include:

In previous versions, Django used “naive” date/times (that is, date/times without an associated time zone), leaving it up to each developer to interpret what a given date/time “really means”. This can cause all sorts of subtle timezone-related bugs.

Backwards incompatible changes in 1.4¶

SECRET_KEY setting is required¶ Running Django with an empty or known SECRET_KEY disables many of Django’s security protections and can lead to remote-code-execution vulnerabilities. No Django site should ever be run without a SECRET_KEY . In Django 1.4, starting Django with an empty SECRET_KEY will raise a DeprecationWarning . In Django 1.5, it will raise an exception and Django will refuse to start. This is slightly accelerated from the usual deprecation path due to the severity of the consequences of running Django with no SECRET_KEY .

django.contrib.admin ¶ The included administration app django.contrib.admin has for a long time shipped with a default set of static files such as JavaScript, images and stylesheets. Django 1.3 added a new contrib app django.contrib.staticfiles to handle such files in a generic way and defined conventions for static files included in apps. Starting in Django 1.4, the admin’s static files also follow this convention, to make the files easier to deploy. In previous versions of Django, it was also common to define an ADMIN_MEDIA_PREFIX setting to point to the URL where the admin’s static files live on a Web server. This setting has now been deprecated and replaced by the more general setting STATIC_URL . Django will now expect to find the admin static files under the URL <STATIC_URL>/admin/ . If you’ve previously used a URL path for ADMIN_MEDIA_PREFIX (e.g. /media/ ) simply make sure STATIC_URL and STATIC_ROOT are configured and your Web server serves those files correctly. The development server continues to serve the admin files just like before. Read the static files howto for more details. If your ADMIN_MEDIA_PREFIX is set to a specific domain (e.g. http://media.example.com/admin/ ), make sure to also set your STATIC_URL setting to the correct URL – for example, http://media.example.com/ . Warning If you’re implicitly relying on the path of the admin static files within Django’s source code, you’ll need to update that path. The files were moved from django/contrib/admin/media/ to django/contrib/admin/static/admin/ .

Supported browsers for the admin¶ Django hasn’t had a clear policy on which browsers are supported by the admin app. Our new policy formalizes existing practices: YUI’s A-grade browsers should provide a fully-functional admin experience, with the notable exception of Internet Explorer 6, which is no longer supported. Released over 10 years ago, IE6 imposes many limitations on modern Web development. The practical implications of this policy are that contributors are free to improve the admin without consideration for these limitations. This new policy has no impact on sites you develop using Django. It only applies to the Django admin. Feel free to develop apps compatible with any range of browsers.

Removed admin icons¶ As part of an effort to improve the performance and usability of the admin’s change-list sorting interface and horizontal and vertical “filter” widgets, some icon files were removed and grouped into two sprite files. Specifically: selector-add.gif , selector-addall.gif , selector-remove.gif , selector-removeall.gif , selector_stacked-add.gif and selector_stacked-remove.gif were combined into selector-icons.gif ; and arrow-up.gif and arrow-down.gif were combined into sorting-icons.gif . If you used those icons to customize the admin, then you’ll need to replace them with your own icons or get the files from a previous release.

CSS class names in admin forms¶ To avoid conflicts with other common CSS class names (e.g. “button”), we added a prefix (“field-“) to all CSS class names automatically generated from the form field names in the main admin forms, stacked inline forms and tabular inline cells. You’ll need to take that prefix into account in your custom style sheets or JavaScript files if you previously used plain field names as selectors for custom styles or JavaScript transformations.

Compatibility with old signed data¶ Django 1.3 changed the cryptographic signing mechanisms used in a number of places in Django. While Django 1.3 kept fallbacks that would accept hashes produced by the previous methods, these fallbacks are removed in Django 1.4. So, if you upgrade to Django 1.4 directly from 1.2 or earlier, you may lose/invalidate certain pieces of data that have been cryptographically signed using an old method. To avoid this, use Django 1.3 first for a period of time to allow the signed data to expire naturally. The affected parts are detailed below, with 1) the consequences of ignoring this advice and 2) the amount of time you need to run Django 1.3 for the data to expire or become irrelevant. contrib.sessions data integrity check Consequences: The user will be logged out, and session data will be lost. Time period: Defined by SESSION_COOKIE_AGE .

data integrity check contrib.auth password reset hash Consequences: Password reset links from before the upgrade will not work. Time period: Defined by PASSWORD_RESET_TIMEOUT_DAYS .

password reset hash Form-related hashes: these have a much shorter lifetime and are relevant only for the short window where a user might fill in a form generated by the pre-upgrade Django instance and try to submit it to the upgraded Django instance: contrib.comments form security hash Consequences: The user will see the validation error “Security hash failed.” Time period: The amount of time you expect users to take filling out comment forms.

form security hash FormWizard security hash Consequences: The user will see an error about the form having expired and will be sent back to the first page of the wizard, losing the data entered so far. Time period: The amount of time you expect users to take filling out the affected forms.

security hash CSRF check Note: This is actually a Django 1.1 fallback, not Django 1.2, and it applies only if you’re upgrading from 1.1. Consequences: The user will see a 403 error with any CSRF-protected POST form. Time period: The amount of time you expect user to take filling out such forms.

contrib.auth user password hash-upgrade sequence Consequences: Each user’s password will be updated to a stronger password hash when it’s written to the database in 1.4. This means that if you upgrade to 1.4 and then need to downgrade to 1.3, version 1.3 won’t be able to read the updated passwords. Remedy: Set PASSWORD_HASHERS to use your original password hashing when you initially upgrade to 1.4. After you confirm your app works well with Django 1.4 and you won’t have to roll back to 1.3, enable the new password hashes.

user password hash-upgrade sequence

django.contrib.flatpages ¶ Starting in 1.4, the FlatpageFallbackMiddleware only adds a trailing slash and redirects if the resulting URL refers to an existing flatpage. For example, requesting /notaflatpageoravalidurl in a previous version would redirect to /notaflatpageoravalidurl/ , which would subsequently raise a 404. Requesting /notaflatpageoravalidurl now will immediately raise a 404. Also, redirects returned by flatpages are now permanent (with 301 status code), to match the behavior of CommonMiddleware .

supports_timezone changed to False for SQLite¶ The database feature supports_timezone used to be True for SQLite. Indeed, if you saved an aware datetime object, SQLite stored a string that included an UTC offset. However, this offset was ignored when loading the value back from the database, which could corrupt the data. In the context of time-zone support, this flag was changed to False , and datetimes are now stored without time-zone information in SQLite. When USE_TZ is False , if you attempt to save an aware datetime object, Django raises an exception.

MySQLdb -specific exceptions¶ The MySQL backend historically has raised MySQLdb.OperationalError when a query triggered an exception. We’ve fixed this bug, and we now raise django.db.DatabaseError instead. If you were testing for MySQLdb.OperationalError , you’ll need to update your except clauses.

Database connection’s thread-locality¶ DatabaseWrapper objects (i.e. the connection objects referenced by django.db.connection and django.db.connections["some_alias"] ) used to be thread-local. They are now global objects in order to be potentially shared between multiple threads. While the individual connection objects are now global, the django.db.connections dictionary referencing those objects is still thread-local. Therefore if you just use the ORM or DatabaseWrapper.cursor() then the behavior is still the same as before. Note, however, that django.db.connection does not directly reference the default DatabaseWrapper object anymore and is now a proxy to access that object’s attributes. If you need to access the actual DatabaseWrapper object, use django.db.connections[DEFAULT_DB_ALIAS] instead. As part of this change, all underlying SQLite connections are now enabled for potential thread-sharing (by passing the check_same_thread=False attribute to pysqlite). DatabaseWrapper however preserves the previous behavior by disabling thread-sharing by default, so this does not affect any existing code that purely relies on the ORM or on DatabaseWrapper.cursor() . Finally, while it’s now possible to pass connections between threads, Django doesn’t make any effort to synchronize access to the underlying backend. Concurrency behavior is defined by the underlying backend implementation. Check their documentation for details.

IGNORABLE_404_STARTS and IGNORABLE_404_ENDS settings¶ Until Django 1.3, it was possible to exclude some URLs from Django’s 404 error reporting by adding prefixes to IGNORABLE_404_STARTS and suffixes to IGNORABLE_404_ENDS . In Django 1.4, these two settings are superseded by IGNORABLE_404_URLS , which is a list of compiled regular expressions. Django won’t send an email for 404 errors on URLs that match any of them. Furthermore, the previous settings had some rather arbitrary default values: IGNORABLE_404_STARTS = ( '/cgi-bin/' , '/_vti_bin' , '/_vti_inf' ) IGNORABLE_404_ENDS = ( 'mail.pl' , 'mailform.pl' , 'mail.cgi' , 'mailform.cgi' , 'favicon.ico' , '.php' ) It’s not Django’s role to decide if your website has a legacy /cgi-bin/ section or a favicon.ico . As a consequence, the default values of IGNORABLE_404_URLS , IGNORABLE_404_STARTS , and IGNORABLE_404_ENDS are all now empty. If you have customized IGNORABLE_404_STARTS or IGNORABLE_404_ENDS , or if you want to keep the old default value, you should add the following lines in your settings file: import re IGNORABLE_404_URLS = ( # for each <prefix> in IGNORABLE_404_STARTS re . compile ( r '^<prefix>' ), # for each <suffix> in IGNORABLE_404_ENDS re . compile ( r '<suffix>$' ), ) Don’t forget to escape characters that have a special meaning in a regular expression, such as periods.

CSRF protection extended to PUT and DELETE¶ Previously, Django’s CSRF protection provided protection only against POST requests. Since use of PUT and DELETE methods in AJAX applications is becoming more common, we now protect all methods not defined as safe by RFC 2616 – i.e., we exempt GET, HEAD, OPTIONS and TRACE, and we enforce protection on everything else. If you’re using PUT or DELETE methods in AJAX applications, please see the instructions about using AJAX and CSRF.

Password reset view now accepts subject_template_name ¶ The password_reset view in django.contrib.auth now accepts a subject_template_name parameter, which is passed to the password save form as a keyword argument. If you are using this view with a custom password reset form, then you will need to ensure your form’s save() method accepts this keyword argument.

django.core.template_loaders ¶ This was an alias to django.template.loader since 2005, and we’ve removed it without emitting a warning due to the length of the deprecation. If your code still referenced this, please use django.template.loader instead.

django.db.models.fields.URLField.verify_exists ¶ This functionality has been removed due to intractable performance and security issues. Any existing usage of verify_exists should be removed.

django.core.files.storage.Storage.open ¶ The open method of the base Storage class used to take an obscure parameter mixin that allowed you to dynamically change the base classes of the returned file object. This has been removed. In the rare case you relied on the mixin parameter, you can easily achieve the same by overriding the open method, like this: from django.core.files import File from django.core.files.storage import FileSystemStorage class Spam ( File ): """ Spam, spam, spam, spam and spam. """ def ham ( self ): return 'eggs' class SpamStorage ( FileSystemStorage ): """ A custom file storage backend. """ def open ( self , name , mode = 'rb' ): return Spam ( open ( self . path ( name ), mode ))

YAML deserializer now uses yaml.safe_load ¶ yaml.load is able to construct any Python object, which may trigger arbitrary code execution if you process a YAML document that comes from an untrusted source. This feature isn’t necessary for Django’s YAML deserializer, whose primary use is to load fixtures consisting of simple objects. Even though fixtures are trusted data, the YAML deserializer now uses yaml.safe_load for additional security.

Session cookies now have the httponly flag by default¶ Session cookies now include the httponly attribute by default to help reduce the impact of potential XSS attacks. As a consequence of this change, session cookie data, including sessionid, is no longer accessible from JavaScript in many browsers. For strict backwards compatibility, use SESSION_COOKIE_HTTPONLY = False in your settings file.

The urlize filter no longer escapes every URL¶ When a URL contains a %xx sequence, where xx are two hexadecimal digits, urlize now assumes that the URL is already escaped and doesn’t apply URL escaping again. This is wrong for URLs whose unquoted form contains a %xx sequence, but such URLs are very unlikely to happen in the wild, because they would confuse browsers too.

assertTemplateUsed and assertTemplateNotUsed as context manager¶ It’s now possible to check whether a template was used within a block of code with assertTemplateUsed() and assertTemplateNotUsed() . And they can be used as a context manager: with self . assertTemplateUsed ( 'index.html' ): render_to_string ( 'index.html' ) with self . assertTemplateNotUsed ( 'base.html' ): render_to_string ( 'index.html' ) See the assertion documentation for more.

Database connections after running the test suite¶ The default test runner no longer restores the database connections after tests’ execution. This prevents the production database from being exposed to potential threads that would still be running and attempting to create new connections. If your code relied on connections to the production database being created after tests’ execution, then you can restore the previous behavior by subclassing DjangoTestRunner and overriding its teardown_databases() method.

Output of manage.py help ¶ manage.py help now groups available commands by application. If you depended on the output of this command – if you parsed it, for example – then you’ll need to update your code. To get a list of all available management commands in a script, use manage.py help --commands instead.

extends template tag¶ Previously, the extends tag used a buggy method of parsing arguments, which could lead to it erroneously considering an argument as a string literal when it wasn’t. It now uses parser.compile_filter , like other tags. The internals of the tag aren’t part of the official stable API, but in the interests of full disclosure, the ExtendsNode.__init__ definition has changed, which may break any custom tags that use this class.

Loading some incomplete fixtures no longer works¶ Prior to 1.4, a default value was inserted for fixture objects that were missing a specific date or datetime value when auto_now or auto_now_add was set for the field. This was something that should not have worked, and in 1.4 loading such incomplete fixtures will fail. Because fixtures are a raw import, they should explicitly specify all field values, regardless of field options on the model.

Development Server Multithreading¶ The development server is now is multithreaded by default. Use the runserver --nothreading option to disable the use of threading in the development server: django - admin . py runserver -- nothreading

Attributes disabled in markdown when safe mode set¶ Prior to Django 1.4, attributes were included in any markdown output regardless of safe mode setting of the filter. With version > 2.1 of the Python-Markdown library, an enable_attributes option was added. When the safe argument is passed to the markdown filter, both the safe_mode=True and enable_attributes=False options are set. If using a version of the Python-Markdown library less than 2.1, a warning is issued that the output is insecure.