Thu 09 November 2017 snippets A Django custom command to write model fields on an Excel file 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. You can use …
Wed 10 May 2017 sysadmin A simple Python email gateway 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 …
Tue 02 May 2017 sysadmin How to deploy a Django project in 15 minutes with Ansible In this post I explain how to deploy a Django project in 15 minutes with Ansible. Automate your deploy will save you time and helps in avoiding errors.
Fri 27 May 2016 web How to add CORS headers to a Django view for use with a Cordova app Suppose you want to access some JSON data from a mobile app using Cordova. You have to bypass CORS restrictions in the web view, and to do that you have to provide some HTTP headers in your Django views. You can do this pretty easily by using this mixin in …
Wed 18 May 2016 web How to migrate your existing Django project to Heroku Recently I had some fun with Heroku, the well known PaaS provider. I had a small personal Django project I use for invoicing that I ran locally with ./manage.py runserver when needed. That was a perfect candidate for the Heroku free plan because I need to access the app …
Thu 22 October 2015 snippets A simple script to update a DB migration in Django 1.7+ 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. South had the update flag for the …
Wed 10 September 2014 web How to add a group choice combo box in a Django user profile form 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 …
Wed 25 June 2014 web PUT and DELETE HTTP requests with Django and jQuery Discover how you can support PUT and DELETE HTTP requests in your Django project using jQuery. Add a REST touch to your project!
Sun 13 October 2013 sysadmin Django on windows: how to make Django run in CherryPy as a Windows service 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 …