Web Development
Django 2.0 Release Candidate Now Available
By Kévin Barralon
The Django web framework just published the first release candidate of its upcoming 2.0 version. Django 2.0 is scheduled to be released on December 1st.
Don’t be fooled by the name – this new major release of Django will not bring any major significant changes to the framework. The changes in the latest version should be of the same scale as those found in past new releases.
Despite this, the most important change in the 2.0 release is its incompatibility with Python 2.7, the support for which is scheduled to last only until 2020. Django 2.0 will only support a minimum version of Python 3.4, and of course it is highly recommended to go directly to the most recent version of Python, which is presently 3.6.
URL Routing
In terms of new features, the new function django.urls.path()
renders the URL routing syntax much simpler and easier to read. So, instead of having to write url(r'^articles/(?P[0-9]{4})/$', views.year_archive)
, you can write path('articles//', views.year_archive).
This new syntax will also allow the view to receive the URL arguments with the proper type already defined (a whole number in the case of year above, instead of a string).
It is still not possible to add a constraint to the URL route directly (in this example, the fact that the year should only consist of four digits). The current function django.conf.urls.url()
will be replaced by django.urls.re_path()
which will keep the existing functionality of allowing regular expressions to be placed in the definition of the route.
The functiondjango.conf.urls.include()
will also be directly available under django.urls
. This will allow you to import your modules like from django.urls import include, path
.
Other New Things
Helpful Links:
Deploying Entire Services with Docker Swarm and GitLab CI
by Jacob Cook
Here at Savoir-faire Linux, I work on the deployment infrastructure for many of our hosted services, and am constantly looking for ways to improve our DevOps practice. Currently the deployment pipeline is centered around the use of Ansible to manually provision a service inside a virtual machine and adjust as necessary. But in an effort to make builds and deployments faster and more stable for our developers, we are looking at new approaches, including the use of Docker builds pushed to a registry and subsequently deployed using a pipeline like GitLab CI.
One of the tools that can be used to deploy a micro-service architecture (created with docker-compose
) is called Docker Swarm. Using a set of servers configured to act in a swarm, one can deploy a stack of containers in a simple pattern with only docker stack deploy
. Docker will then automatically choose the appropriate servers in the swarm to deploy to, and handle networking between the services just as if you were using docker-compose
on your local machine. Neat, huh?
The best part is that it plays nicely with our existing build system in GitLab CI. We can build, test, release and deploy across our infrastructure using GitLab CI and GitLab Container Registry. There are still pieces of the puzzle to work out but it represents a major leap forward in the simplification and stability of our DevOps practice.
Further Reading: