In a previous post I described how to deploy a Django project using Ansible. Here I explain how to make a step further and deploy a Django project using Bitbucket Pipelines and Ansible. Bitbucket Pipelines are basically docker containers, hosted…
Suppose you need to write down your model fields on an Excel file, for example to complement the documentation of your code.
Django has built in functions to introspect models and fields of an app, and you can leverage this API to have the information you need.
Say you have a Django web application that you want to integrate with emails to make it possibile to send data and files to your web application over SMTP.
The good news is that Python has a simple SMTP daemon in the standard library, together with modules to parse emails. Let’s see how to create a simple email gateway on top of these tools.
In this tutorial I will explain how to deploy a Django project in 15 minutes with Ansible. I will assume that you are a Django developer and you have built and tested a project locally. It’s time to deploy the project on a public server to let users access your awesome application.
So you need a VPS with an SSH access, then you will access the server, install and configure all necessary software (web server, application server, database server), create a database user, configure Django to use it, copy your Django project on the server, migrate the database, collect static files, trial and error, fix, trial and error, …
All this boring stuff will take some good hours that you should definitely spend in a more profitable way, don’t you think? The good news is that you can automate almost all the work needed to go from a vanilla VPS to a fully deployed server hosting your Django project.
Follow this tutorial and I’ll show you how to leverage the power of Ansible to automate all the needed steps in 15 minutes. Are you ready? Check the time on your clock and follow me!
During the development of a Django model on your local machine is it often necessary to refine the most recent migration to cope with updates to the model, without polluting the migrations of the app with a new migration for each local update.
So I put togheter a simple bash script to automate the process.
Recently I had a problem of memory usage in Django: when I accessed an apparently innocent view I saw the memory usage of my server grow without rest. The problem turned out to be very trivial to solve, but I think the process I used to find the leak is worth a blog post. 😉
Assume that you have a Django project where each user belongs to just one group, say Registered or Admin, but not both.
You want to show a form in your front-end to let Admin users edit the user profiles, where each user profile is made with First name, Last name, Email and the user group.
This task can be accomplished very easily! What you need is a customized ModelForm to add the possibility to edit the user group together with the other fields, and a customized UpdateView to let you set the form initial data for the group field, and to save the changes correctly.
Sometimes it could be useful and elegant to have a Django view responding to more that GET and POST requests, implementing a simple REST interface. In this post I’ll show how you can support PUT and DELETE HTTP requests in Django.
Recently a client asked me to investigate the possibility to have a Django application hosted in a Windows environment. I looked around a bit and there are many ways to achieve this goal. I found the “pure Python” approach described here simpler to deploy and configure, yet very powerful and production ready for my needs.
I will explain how to install Python, CherryPy and Django on Windows, and how to configure them to serve a Django application from the CherryPy WSGI server, running as a Windows service.