Django 2.0 released

The Django project has today announced the release of Django 2.0!

The Django team is happy to announce the release of Django 2.0. […]

You can get Django 2.0 from our downloads page or from the Python Package Index.

The release of Django 2.0 moves prior versions …

Continue reading »

Django 2.0 release candidate 1 available

The Django project has today announced the availability of Django 2.0 release candidate 1.

Django 2.0 release candidate 1 is the final opportunity for you to try out the assortment of new features before Django 2.0 is released.

This is a further increase in stability, as the …

Continue reading »

What's in a name? That's up to you

The abstract models for users in Django allows many applications to define a custom User model easily. There is an aspect which is problematic for a general-purpose framework: names of people.

The default assumption: first_name and last_name

On the AbstractUser model – and therefore by default on any subclass, such as …

Continue reading »

Query results, finely ordered

Django's QuerySet API allows you to express the concept of the “latest” and “earliest” instance from a set. What does “latest” mean for your data? Django can't guess, so you need to specify that:

from django.db import models

class Subscription(models.Model):
    """ A subscription to our magazine. """

    created = models …

Continue reading »

Keyword-only parameters for more explicit API

When you define a function, you're defining an API. To help write more explicit APIs, Python 3 allows you to write the function's parameters so that some of them are keyword-only. A keyword-only parameter gets its value only from a keyword argument in the call syntax.

def frobnicate(lorem, ipsum …

Continue reading »

Django 2.0 beta 1 available

The Django project has today announced the availability of Django 2.0 beta 1. This is an increase in stability, as the bar is now higher for changes that can be made:

Django 2.0 beta 1 is an opportunity for you to try out the assortment of new features …

Continue reading »

Extract parts of temporal values (date, time, duration)

Temporal values in Python (from the ‘datetime’ library) represent dates, instants, and durations. The Django temporal field types represent those values on a data model.

What if we want only a part of a temporal value, such as the month, the day-of-week, or the minute-of-hour?

Query expressions and database functions …

Continue reading »

Reading data fixtures from stdin

Data model instances can be serialised to various formats; the resulting serialised data can be used later as a “data fixture” for the ‘loaddata’ management command, to populate the same or a different database.

In Django 2.0, the loaddata command can read the fixture from the standard input.

Standard …

Continue reading »

Why release 2.0?

Django “1.0” was released in 2008. Every release for the following 9 years had the major version “1”. Why did the Django project decide that this release merits increasing to major version “2”?

Release cadence

The Django release process document explains:

Starting with Django 2.0, version numbers will …

Continue reading »

Here comes Django 2.0

After a lot of development, Django 2.0 has its first alpha release today!

In this series we look at the new features coming in this major release.

To start, let's look at a feature that addresses some pain for many site administrators: mobile device support.

Mobile-friendly admin site

From …

Continue reading »