Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Filepicker.io and South
I've heard good things about filepicker.io, which is a service that makes file uploading a much better experience. Unfortunately, the Django package for filepicker.io doesn't work with South. When I try to create a migration using the filepicker.io field using code like the following... # products/models.py from django.db import models from django_filepicker.models import FPFileField class Product(models.Model): title = models.CharField(max_length=255) file = FPFileField(upload_to='uploads') ...when I try to run the command: (tsd)$ python manage.py schemamigration products --initial It results in this unpleasant looking response: (tsd)$ python manage.py schemamigration products --initial Creating migrations directory at '/Users/danielgreenfeld/code/tsp/tsp/products/migrations'... Creating __init__.py in '/Users/danielgreenfeld/code/tsp/tsp/products/migrations'... ! Cannot freeze field 'products.product.fpfile' ! (this field has class django_filepicker.models.FPFileField) ! Cannot freeze field 'products.release.fpfile' ! (this field has class django_filepicker.models.FPFileField) ! South cannot introspect some fields; this is probably because they are custom ! fields. If they worked in 0.6 or below, this is because we have removed the ! models parser (it often broke things). ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork The last line in the error report is important. I'll repeat it to illustrate it more clearly: ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork Experience working on other projects has taught me I can simply add two lines of code … -
PUN: Python Usergroup Nederland: what is it?
Summary: 6-8 free meetings per year with a couple of talks and some drinks afterwards. Find new meetings on the Dutch Django association meetup page. The Python Usergroup Netherlands (PUN) is "that which I make summaries of :-)". So I sometimes get the question "what is it?" in my inbox. I got one such question yesterday, so I'll blog my answer :-) The evenings Mostly, the PUN means a meeting every couple of months. The format is two 30-minute talks and 6 5-minute "lightning talks". In the lightning talks everybody can introduce a project (s)he worked on lately, for instance. The bigger 30-minute talks can be anything from "this is how we use python at company XYZ", "3D prototyping with Python", "Plone's new layout engine", etc. The talks are normally in English as not everyone understands Dutch. If we suspect there are only native Dutch speakers around someone might ask whether everyone understands Dutch, in that case we just speak Dutch, naturally :-) Some separate notes: The evenings are free. You don't need to be a member and you don't need to register. Registering (=clicking "I'll be there" on meetup.com) is appreciated, though, as it gives the organizer an idea … -
Off to Europe!
I feel like I'm dreaming, but we're on our way to Europe! A few weeks Audrey and I decided to move. While looking at possible rentals or even mortgages, we were idly (dreaming really... still paying off debts incurred from last year) looking at how much a room/apartment would cost to rent in Europe. To our surprise, we found a lot of good options that cost less then it would to pay monthly rent/mortgage in Los Angeles. o_O Then, we discovered an amazing travel deal. It combined a very cheap red-eye flight from Los Angeles to Fort Lauderdale, and a slow trans-atlantic ship from Port Miami to Barcelona, about as much as a cheap hotel but with free food! If we avoid alcohol and any extra fees, it's actually extremely inexpensive. Being mostly disconnected from the internet would mean we could really focus on a couple of critical projects. If only we had a business justification for going to Europe... It just so happens that we have business in Europe. Our plan is to spend a few months in Europe before returning back to the USA. We'll work hard on the ship, work hard when we arrive, and just get … -
Off to Europe!
I feel like I'm dreaming, but we're on our way to Europe! A few weeks Audrey and I decided to move. While looking at possible rentals or even mortgages, we were idly (dreaming really... still paying off debts incurred from last year) looking at how much a room/apartment would cost to rent in Europe. To our surprise, we found a lot of good options that cost less then it would to pay monthly rent/mortgage in Los Angeles. o_O Then, we discovered an amazing travel deal. It combined a very cheap red-eye flight from Los Angeles to Fort Lauderdale, and a slow trans-atlantic ship from Port Miami to Barcelona, about as much as a cheap hotel but with free food! If we avoid alcohol and any extra fees, it's actually extremely inexpensive. Being mostly disconnected from the internet would mean we could really focus on a couple of critical projects. If only we had a business justification for going to Europe... It just so happens that we have business in Europe. Our plan is to spend a few months in Europe before returning back to the USA. We'll work hard on the ship, work hard when we arrive, and just get … -
Summary of the Dutch Python meeting in Delft
We had a Python meeting tonight (18 april 2013) in Delft at the fox IT offices. I especially liked the open source marketing talk, telling us how to properly tell others about our great projects. (Note: my brother Maurits also made a summary) Github test commit info - Reinout van Rees I gave a quick lighting talk about my githubinfo script that gives you reports on the amount of tests in the last week per project and per developer. Handy for raising awareness for testing amongst your colleages if you mail around the results once a week! The source code is at https://github.com/nens/githubinfo . I already blogged about it, so you can read more there. Devops at fox IT - Ronald Evers Ronald works on detact, a fraud detection for online banking, trying to detect fraud in http traffic for online banking. They sell it to banks. The low-level stuff is in c++, the rest in Python. How do they make it? They use git, so they can use Gerrit, a code review tool. Every commit gets pushed first into a special gerrit branch on github and ends up in the gerrit tool. Every commit needs two upvotes before it … -
Caktus sponsoring and speaking on mobile health at SwitchPoint 2013
SwitchPoint is a one-of-a-kind conference and a unique opportunity to learn, share ideas, and hear about global and mobile health efforts around the world. We had a great time at SwitchPoint last year. I’m excited to announce that Caktus, for the second year in a row, is sponsoring SwitchPoint 2013. At Caktus, we enjoy working on projects that have a positive social impact and have had the opportunity to implement mobile health projects around the world, including in Nigeria, Rwanda, Zambia and Malawi. Caktus currently leads the development of RapidSMS, a free and open-source framework (built in Django) for dynamic data collection, logistics coordination and communication through text messaging (SMS). RapidSMS is used widely across Africa and other parts of the world to improve patient outcomes and save lives in urban and rural areas. Over the past 11 months, Caktus has organized efforts around improving the RapidSMS core codebase, including infrastructure enhancements and coordinating community involvement and participation. Additionally, Caktus is collaborating on UNICEF’s 1000 Days Product, which tracks the first 1000 days between a woman’s pregnancy and her child’s second birthday. 1000 days not only tracks nutrition, which is very important during early child development, but also includes mobile … -
Scheduling Periodic Tasks with Celery 2.3.3 and Django 1.4
There are going to be times in the life of your application when you'll need to perform tasks - making requests to APIs, sending emails, or storing large amounts of data, for example. To do that, you'll most likely want to implement some sort of job queue - that is, a system that lines these tasks up and executes them. Celery is a task queue commonly used with Django - it's open source, easy to integrate with many other languages and frameworks, and it can execute tasks either asynchronously (in the background) or synchronously (wait until ready). This article is going to talk about a very basic Celery implementation for Django - you'll need to have Django installed already, and we'll discuss installing and configuring celery, django-celery (Celery integration for Django), and RabbitMQ (the recommended message broker for celery). If you're using an older version of Celery, it may be a little challenging finding the right docs - for 2.3.3, start with this link: http://docs.celeryproject.org/en/v2.3.3/ And you may want to bookmark this for future reference - the Celery account on GitHub contains repositories for the official celeryproject, as well as django-celery and kombu. https://github.com/celery Installing and configuring Before you get … -
Two Scoops of Django is in print!
Since I was a child I wanted to be a published author. I've dreamt of people reading my book. While one could say that dream was fulfilled when we launched the e-book version in January, it's not the same as seeing the printed copy. Today I got to see my dream come true, a printed book is out there with my name on it. Also, I have a confession to make. When it comes to technical books, I really prefer the print version. For me, nothing beats being able to flip through pages of a hardcopy next to a keyboard, or simply reading while I'm on a bus, train, or plane. So this adds to my excitement when I get to say that the book that Audrey Roy and I wrote together is in print. Note: As of April 17th it's only available in the US. However, it's in the queue for being available for Amazon Europe. Enough people are asking that we are also looking into getting it bulk shipped to Django Circus. While it's been an amazing journey, it's also been a long hard road. Starting with a late night dinner with Randall Degges, his wife Samantha, and … -
Two Scoops of Django is in print!
Since I was a child I wanted to be a published author. I've dreamt of people reading my book. While one could say that dream was fulfilled when we launched the e-book version in January, it's not the same as seeing the printed copy. Today I got to see my dream come true, a printed book is out there with my name on it. Also, I have a confession to make. When it comes to technical books, I really prefer the print version. For me, nothing beats being able to flip through pages of a hardcopy next to a keyboard, or simply reading while I'm on a bus, train, or plane. So this adds to my excitement when I get to say that the book that Audrey Roy and I wrote together is in print. Note: As of April 17th it's only available in the US. However, it's in the queue for being available for Amazon Europe. Enough people are asking that we are also looking into getting it bulk shipped to Django Circus. While it's been an amazing journey, it's also been a long hard road. Starting with a late night dinner with Randall Degges, his wife Samantha, and … -
Logging time, part 1: github for timelogging
I've got to keep track of what I work on. The company I work for (Nelen & Schuurmans) is pretty much focused on projects, so that's what you should book your hours on. This is both for billing to clients and for internal bookkeeping: projects should be profitable, ideally, so we need to keep track of it. Now... how to do this? I fill in my hours two or three times during the month. And my memory isn't that good that I remember everything. So I look in my agenda for free days, meetings, that sort of stuff. But the majority of my work isn't in my agenda, it is in code. And the code... is in github, mostly. So what I do when filling in my hours is looking at the github timeline. See https://github.com/reinout, at the bottom is my contribution activity. That tells me enough on what I did in the last week. A different view is gitspective, see for instance my timeline. It gives you a different timeline, better for filling in your hours than github's. Apart from one detail: it misses the private repositories you worked on. And our Django sites are all private because of … -
Logging time, part 2: gtimelog on the commandline
Using github for timelogging is fine, but I longed back to the days when I used a hacked-up of gtimelog that worked on the commandline. I looked in my private git repository with my old subversion stuff and found it. Why gtimelog? Well, in my case, on the commandline, it works quite well. Type in tl weblog on the commandline when I've written a blog entry. Type in tl ror_export when I've worked on that particular project. I've hooked up commandline completion. The end result is a timelog.txt file with a simple line-based format: 2013-04-16 09:36: arrived** 2013-04-16 10:08: compu 2013-04-16 10:31: omnifocus 2013-04-16 11:15: neerslagradar 2013-04-16 11:37: email_en_newsgroups 2013-04-16 11:50: email_en_newsgroups 2013-04-16 12:30: lizard_unbillable 2013-04-16 13:15: lunch** You can modify it afterwards if needed. Lightweight. I get a daily or weekly report out of it like this: Blokkendoos 3 hours 24 min Compu 32 min Email_en_newsgroups 35 min Lizard_unbillable 2 hours 6 min Neerslagradar 44 min The regular gtimelog requires gtk, which isn't handy on OSX. On debian/ubuntu you can apt-get install it. You get a window-based interface that way and can click entries and have a constant overview and so. That said, I hacked up a modified version … -
Django and RequireJS
Until very recently, I was very happy with [django-compressor](http://django-compressor.readthedocs.org/en/latest/). It does a great job of combining and minifying static media files, specifically JavaScript and CSS files. It will manage compilation, allowing you to use, for example, SASS and CoffeeScript. Not that I do. But, for me, the best part was the cache invalidation. By combining JavaScript (or CSS) into files that get named according to a hash of their contents, it's trivial for clients to not have an old cached JS or CSS file. However, recently I have begun using [RequireJS](http://requirejs.org). This enables me to declare dependencies, and greatly simplify the various pages within my site that use specific JavaScript modules. But this does not play so well with django-compressor. The problem lies with the fact that there is no real way to tell RequireJS that "instead of ``js/file.js``, it should use ``js/file.123ABC.js``", where ``123ABC`` is determined by the static files caching storage. RequireJS will do optimisation, and this includes combining files, but that's not exactly what I want. I could create a built script for each page that has a ``require()`` call in it, but that would mean ``jQuery`` etc get downloaded seperately for each different script. I have … -
Django for Web Prototyping
Or how to use the benefits of Django template system during the PSD to HTML phase There are two main approaches to start designing a new project – Photoshop mock-up or an HTML prototype. The first one is more traditional and well established in the web industry. The second one is more alternative and (maybe)modern. I remember a video of Jason Fried from 37 Signals where he talks about design and creativity. You can see it at http://davegray.nextslide.com/jason-fried-on-design. There he explains how he stays away from the Photoshop in the initial phase to concetrate on the things that you can interact with instead of focusing on design details. I am not planning to argue which is the better method, the important thing here is that sooner or later you get to the point where you have to start the HTML coding. Unfortunately frequently this happens in a pure HTML/CSS environment outside of the Django project and then we waste some extra amount of time to convert it to Django templates. Wouldn’t be awesome if you can give the front-end developers something that they can install/run with a simple command and still to allow them to work in the Django environment … -
Generating NCX files with Python
With the help of fellow Python developer Matt Harrison's excellent Ebook Formatting: KF8, Mobi & EPUB, we managed to create pretty decent looking Kindle and ePub versions of Two Scoops of Django. One of many things we did was focus on providing an excellent table of contents. Of course we provided one inside the content of the book, but much like the PDF version we also provided one that various ebook readers can display in sidebars or drop down menus. Unfortunately, building this navigation isn't well documented (except for Matt's book), and I've yet to see any good ways to generate it via code. Which is why I present the following code. It looks at the HTML that KindleGen and ePub generators demand and pulls from it a chapter-based table of contents. Then constructs a .ncx file, which is what ebook readers use to generate the sidebar/dropdown table of contents. Our requirements: Jinja2 Django BeautifulSoup4 And now the code: #!/usr/bin/python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup from django.utils.text import slugify from jinja2 import Template TEMPLATE = Template("""<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en"> <head> <!-- The content of dtb:uid must … -
Generating NCX files with Python
With the help of fellow Python developer Matt Harrison's excellent Ebook Formatting: KF8, Mobi & EPUB, we managed to create pretty decent looking Kindle and ePub versions of Two Scoops of Django. One of many things we did was focus on providing an excellent table of contents. Of course we provided one inside the content of the book, but much like the PDF version we also provided one that various ebook readers can display in sidebars or drop down menus. Unfortunately, building this navigation isn't well documented (except for Matt's book), and I've yet to see any good ways to generate it via code. Which is why I present the following code. It looks at the HTML that KindleGen and ePub generators demand and pulls from it a chapter-based table of contents. Then constructs a .ncx file, which is what ebook readers use to generate the sidebar/dropdown table of contents. Our requirements: Jinja2 Django BeautifulSoup4 And now the code: #!/usr/bin/python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup from django.utils.text import slugify from jinja2 import Template TEMPLATE = Template("""<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en"> <head> <!-- The content of dtb:uid must … -
Bundling dependencies
This post is about maintenance programming and the issue of Open Source dependencies that may need customising. It compiles some of my current thoughts, but I'm also eager to find out what other people do. 3 approaches to dependencies Pure dependency The source code of the dependency does not become a part of your project in any way. For a web project with Python and virtualenv/pip, you would just list the project name and version in requirements.txt, and it will be installed when you deploy your project. This is by far the easiest approach to dependencies. Forked dependency You create a fork of the library (usually hosted publicly, but not necessarily) and add to it the changes you need. You then use this fork from your main project. This is done either in the hope that bug fixes and feature additions that you make will be merged into the original, so that you won't have to maintain your fork forever, or with the aim of keeping your changes small enough that it will always be easy to merge in fixes from upstream. Bundled dependency You take a copy of the library, and include it directly into your own source code, … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
A whole load of Kickstarting
When I launched my Kickstarter campaign, I didn't quite expect this level of response... It's an odd thing, the internet. Back when I was just starting out doing freelance work - at the ripe old age of fifteen - I remember my mother being slightly bemused that people on the internet were giving me money. Of course, that was for work I had already completed, but in this modern age, it's now possible to raise money before you've even started. My Kickstarter campaign was a simple request - I have some free time, a specific project to build, and a pretty good idea of how to build it. Why not see if the community would contribute? NoteI almost added a £20,000 stretch goal to remove MySQL support entirely. Almost. Oh, how they did. The Kickstarter closed at a whopping £17,952 - 718% of my original £2,500 request. Not only that, but it was funded in 65 minutes and my highest stretch goal (£7,000) was reached in four hours. That Friday was one of the most surreal days of my life - watching the Kickstarter page and Twitter as both donations and messages of support came streaming in. 507 people contributed … -
A helper script for runserver
My Django runserver shortcut script This is a little shell script I save as rs, put on my path, and use as a shortcut to start the Django development server. It has several features that make me more productive: It’s shorter to type than python manage.py runserver. It recognizes what project I’m in and runs many of them on different ports. It opens the web site’s front page in my browser. Running my most important projects on separate ports has a couple of advantages: I can run several simultaneously. My browser can differentiate the projects. When everything runs at localhost:8000, my browser might cache a file like style.css and have no way of knowing when I switch projects and style.css is completely different. If one project is at localhost:8001 and the other is at localhost:8002, the cache keeps them separate. It opens the current site in my browser (after giving the server a few seconds to start) because that’s typically what I do next anyway, and it saves me having to keep track of which project uses which port. If I already have the site open in my browser, I just pass “.” as the first command line argument and … -
Announcing WSGI X-Sendfile: High-Performance File Transfer for Python/WSGI Applications
I'm pleased to announce the first public release of WSGI X-Sendfile, a library that lets your Python/WSGI application serve static files via your Web server.Modern Web servers like Nginx are generally able to serve files faster, more efficiently and more reliably than any Web application they host. These servers are also able to send to the client a file on disk as specified by the Web applications they host. This feature is commonly known as X-Sendfile.This simple library makes it easy for any WSGI application to use X-Sendfile, so that they can control whether a file can be served or what else to do when a file is served, without writing server-specific extensions. Use cases include:Restrict document downloads to authenticated users.Log who’s downloaded a file.Force a file to be downloaded instead of rendered by the browser, or serve it with a name different from the one on disk, by setting the Content-Disposition header.This code has been used in production for three years, but is now being released as beta in case there are bugs that haven't become evident in our systems.Get it while it's hot! -
Announcing WSGI X-Sendfile: High-Performance File Transfer for Python/WSGI Applications
I'm pleased to announce the first public release of WSGI X-Sendfile, a library that lets your Python/WSGI application serve static files via your Web server. Modern Web servers like Nginx are generally able to serve files faster, more efficiently and more reliably than any Web application they host. These servers are also able to send to the client a file on disk as specified by the Web applications they host. This feature is commonly known as X-Sendfile. This simple library makes it easy for any WSGI application to use X-Sendfile, so that they can control whether a file can be served or what else to do when a file is served, without writing server-specific extensions. Use cases include: Restrict document downloads to authenticated users. Log who’s downloaded a file. Force a file to be downloaded instead of rendered by the browser, or serve it with a name different from the one on disk, by setting the Content-Disposition header.This code has been used in production for three years in our Django application, but is now being released as beta in case there are bugs that haven't become evident in our systems. Get it while it's hot! -
Progress Report for March 26th
Reflections on my progress and plans*Update: I had thought I had previously published this post on March 26th, but obviously I did not.The last week has been hectic, but quite productive for Team Django. The team has created a new version of our project poster. Additionally, we have been working on ticket #19224, and creating a rough version of our final presentation slides. A piece of interesting news is the Schema Migrations for Django kickstarter. Andrew Godwin, creator and maintainer of Django South, has proposed adding schema migrations to the Django core. Yes, this isn't an "official" Django proposal. Yes, he did get the approval of the other core contributors. He has raised an incredible amount of money, $23,000 as of March 26th. -
Satchmo 0.9.2 Released
Satchmo 0.9.2 is released. This release of satchmo includes many updates and improvements.