Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Accept Credit Cards in Django with Authorize.Net
Accepting credit cards in your Django applications using the Authorize.Net payment gateway is easier than you might think. -
How to Add Django Database Caching in 5 Minutes
Milk my Caching for all it’s worth One of our big challenges at Yipit as an aggregator has been weaning ourselves off of all of those dastardly MySQL Joins. As Uncle Ben once warned Peter Parker, “With great power comes interminably long queries”. Fortunately, because our workload skews heavily towards reads, we’ve had success implementing various caching strategies across the stack. On the application level, we’ve leveraged Django’s built-in caching framework to enable site-wide caching for anonymous users, view level caching for authenticated pages (especially useful for our API), and ad-hoc caching for aggregate queries. Lately, we’ve begun to dive more deeply into the holy grail of Django data retrieval: cached QuerySets. Conveniently, there are a number of quality libraries available to facilitate this sort of thing, including Johnny Cache, Django Cache-Bot, and Django Cache Machine. We’ve decided to go with Cache Machine for the foreseeable future thanks to its dead simple integration, its common sensical handling of invalidation (including through Foreign Key relationships), useful ancillary features such as caching RawQuerySets and QuerySet counts, and its easy extensibility. A Quick Recap of How Cache Machine Works Cache Machine stores full model QuerySets as key value pairs in one of three … -
Made Up Statistics
At DjangoCon my good friend Miguel Araujo and I presented on Advanced Django Form Usage. Slide 18 of that talk mentioned some made up statistics. Here they are for reference:91% of Django projects use ModelForms.80% ModelForms require trivial logic.20% ModelForms require complex logic.Important Disclaimer: These numbers were cooked out of thin air by yours truly. I determined them with zero research, they carry absolutely not scientific weight, and shouldn't be used in any serious argument. They are wholly my opinion, which is good or bad depending on your point of view and your own opinion of my opinions.With that out of the way, I'm going to make a bar graph out of my fictional data:You'll notice that my bar titles could be stronger. I actually did that on purpose in case anyone tries to use that chart in real life. In any case, if you thought that was interesting, then read on. I have many more made-up statistics. For example, here are more numbers I've cooked up:Pydanny Made Up DevOps StatisticsDevOps is the new hotness. I know because every other Python meetup features someone speaking on it - just like every other Ruby, Perl, and PHP meetup. Anyway... numbers:24.3% Python developers … -
JsLint Checker for Sublime Text 2 with jslint4java
Just finished small JsLint Checker for Sublime Text 2. Configuration of two found on github packages was quite non-trivial from my point of view.I think that clean code is great improvement of development process and speed of development. Also JsLint is very good tool to avoid stupid errors like variables global scope leaks and so on.Check it out on github -
Code Month: Post Mortem
I had meant to post something on the first, but life got away from me in a crazy way. Last month, I talked about doing a Nanowrimo-style sprint-of-one for getting a website up. How'd that turn out? I didn't get the site up (otherwise, you would have had a joyous ... -
Deploying Django to Heroku
Heroku makes life easier for those web developers that just want to deploy our code and it work. In this screencast we walk you through creating a heroku app, deploying your actual code, and running south migrations. This will make development and deployment easier for everyone.Watch Now... -
Deploying Django to Heroku
Heroku makes life easier for those web developers that just want to deploy our code and it work. In this screencast we walk you through creating a heroku app, deploying your actual code, and running south migrations. This will make development and deployment easier for everyone.Watch Now... -
Deploying Django to Heroku
Heroku makes life easier for those web developers that just want to deploy our code and it work. In this screencast we walk you through creating a heroku app, deploying your actual code, and running south migrations. This will make development and deployment easier for everyone.Watch Now... -
The Story of Live-Noting
Like a lot of people, I've got this thing I do when I attend conferences, meetups, classes, and tutorials: I take notes. My open source based ones are mostly written in RestructuredText and I've kept in a particular folder since at least 2006.Putting notes in a DVCSOn September 13, 2009, I uploaded these notes to Github.com. I did that because I wasn't pleased with the workflow I established of moving items to Dropbox for backup. I use DVCS all the time and I figured why not just put my notes where I put my code? So I added my notes as a Github repo.DVCS Notes Based Management System?For a while I tried to use the Github folder README.rst trick to make a navigations system for my notes. But Github isn't designed for making a README into a dynamic custom content navigator, and it would make a silly feature request. I would rather the Github team work on Mercurial integration or other practical things before they honored a request to turn their system into my own custom Notes Management System. Eventually I just gave up on it and moved on.Sphinx + Read The Docs!In early July of 2011 I had a … -
Celery init scripts for Gentoo
I’m using django-celery on a project. The only difficult part was that gentoo ebuilds would not provide init scripts. It might be that some ebuilds in some obscure overlay provides those, but this was far too far away from the mainstream portage tree for me. Yes, the documentation about celery has some scripts using supervisord, [...] -
Django in Production: Part 2 - Background Tasks
This is the second part in a series about Django in Production. If you haven't already, read part 1 here. In my last post, I described in detail the core stack which powers a Django application in production. In this second part, I'll talk about something which has become commonplace in modern web applications - background tasks. Often websites perform complex tasks which take a long time to finish. These tasks don't always need to be done before the response is sent to the browser, so can be executed elsewhere. In cases like this, tasks can be performed asynchronously, by one or more "workers" which consume a task queue. Celery The most common task queue used with Django, at least in my experience, is called Celery. Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. Celery isn't dependant on Django in any way - it's a completely separate application. It does, however, integrate extremely well with Django projects. By installing the django-celery package and then adding djcelery to the list of INSTALLED_APPS, Celery can be run and managed through Django itself - thanks to a set … -
How to contribute translations
Recently we have been asked how to contribute translations to LFS. There are two preferred ways: If your are a (Django-)developer you might want to fork django-lfs and django-lfstheme on bitbucket.org, add the translations as you used to, commit them and send us a pull request. If your are a translator you can just go to transifex, choose or add the language of your choice and start to translate via the web interface. Once you are ready we would add your translations to the source code. If none of these fit your workflow you can of course just send us the translation files :-) If you have further questions don't hesitate to get in touch on one of the following places: Official page Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org Google Group lfsproject on Twitter IRC -
Meta-blog about the blog
I’m going to go a little meta and discuss the aspects of this project behind the project itself. Why would someone want to blog every day? To educate those who don’t know what you do To learn more about a topic you already know – regardless of what you think of your knowledge you will be doing LOTS of research and experimentation along the way. To practice writing and communicating on technical topics. This isn’t easy, and I’ve been “writing” for a while. What does it take? Interest in the topic you’re writing about. A little (or lot!) knowledge helps too. Discipline – nearly every day there’s some degree of “meh I do NOT want to do this, or at least there was for me. Once I reached the 3/4 mark though it switched to “meh I do NOT want to do this, but I’m so dang close to succeeding!” Basic blog software. Like I said at the beginning of the month, my time was better spent writing content that taught than hacking on some blog I could then use. You’ll bikeshed the crap out of a blog you build yourself, don’t fall in this trap. My advice Take it … -
Getting to Continuous Deployment in Django: Feature Flipping
This post is a first in a series of posts about our move towards continuous deployment using Django. Continuous deployment is a process by which code that is written for an application is constantly deployed into production without manual intervention. This allows us to be agile, to quickly innovate, and more importantly, to bounce back from any grave errors, unscathed. When it comes to building new features, this can involve merging feature branches, rigorous code review, testing, and deployments, before you can test it out on a live environment. Every subsequent release to different groups of users would require code changes, and deployment. This can be avoided by employing feature flipping, which is an essential step towards achieving continuous deployment in your application. So what is this feature flipping thing, anyway? In its most basic form, you can think of it as applying an on/off switch to a piece of code in your codebase thereby releasing or rolling back a feature. This allows you to constantly push new code for features that you’re not quite ready to release to any of your users yet. And when you’re ready, you can do a gradual rollout of the feature – to various … -
Developers guide to Running Django Applications on Heroku
Heroku the platform as a service (PAAS) company, very popular in the Ruby on Rails community, has now started opening up their platform to languages besides Ruby. They now offer support for Python, Java, Clojure, Node.js, and Scala on their new Cedar stack. Heroku's Cedar stack is still in beta, but that shouldn't stop you from trying it out, and that is just what I'm going to do. 6 months ago I wrote a series of blog posts that reviewed all of the cool new django hosting services that were popping up. My goal was to look at them all, and compare them to find out what they had to offer, and to see if I could use them on my future projects. I'm going to review Heroku using the same process that I used to review those other services, so that I can we can compare apples to apples. For those of you who are not familiar with my other blog posts, feel free to check them out now ep.io, apphosted.com, gondor.io, dotcloud.com, DjangoZoom.com, Django hosting roundup. For those of you that are lazy, I'll sum it up pretty quickly. What I'm trying to do is pretty simple, I … -
Allowing front-end geographic input
As great as the Django Admin is, it’s not for most of your users. So what do we do to allow user-submitted geometries? Cue django-floppyforms which contains handy widgets we can use with our own forms and modelforms to allow geographic input. Consider this model: class MyArea(models.Model): name = models.CharField(max_length=64, unique=True) point = models.PointField(srid=4326) polygon = models.MultiPolygonField(srid=4326) Throw this in views.py import floppyforms as forms from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext from formstuff.myarea.models import MyArea class OSMPointWidget(forms.gis.PointWidget, forms.gis.BaseOsmWidget): map_srid = 900913 class OSMMultiPolygonWidget(forms.gis.MultiPolygonWidget, forms.gis.BaseOsmWidget): map_srid = 900913 class AreaForm(forms.ModelForm): point = forms.gis.PointField(widget=OSMPointWidget) polygon = forms.gis.MultiPolygonField(widget=OSMMultiPolygonWidget) class Meta: model = MyArea def editing(request): form = AreaForm(request.POST or None) if form.is_valid(): form.save() return HttpResponseRedirect('/') return render_to_response('area.html', { 'form': form, }, context_instance=RequestContext(request)) and users can drop points and polygons on your model, which will be saved into the database. Do you want the Google basemap instead? Extend BaseGMapWidget instead of BaseOsmWidget, remove the srid attrib, and you’re set. It’s amazing how easy those widgets make it – you don’t even have to know you’re dealing with a geometry in your save method. -
Working with files in Django – Part 3
First part of this article is here. How to add STATIC files You will most likely add STATIC files to your source code repository. As they are likely to be hardcoded in your code and templates it is a good idea to keep those and your STATIC files in sync. Your STATIC files are collected [...] -
Many-to-many field, save() method and the Django admin
-
Improving the Admin
The Django admin saves us mountains of time. Back when Django still wasn’t quite Django and it was an internal project it was common for the team to leave a meeting, scribble a schema on a napkin and have the admin ready for data entry in the matter of a couple hours. Models are still my first stop for any project – build the basic frame, and start gathering data with the admin. But over the years we’ve all come to expect more from applications and Django has gotten much better tools for it too. Need to reorder fields? Hide the stuff that rarely gets entered? Use a custom form? It’s in the docs. With the GeoDjango admin though, things aren’t as well documented. So let’s look at some of the simplest things that can make an application better. Changing the default map Two modes are available, admin.GeoModelAdmin and admin.OSMGeoAdmin. GeoModelAdmin uses very simple tiles from OpenLayers that have state lines, rivers / water sources and a few other unmarked areas. I can’t imagine how it would be useful because there’s nothing to reference from, but if you have your own set of WMS tiles you can set wms_url and … -
Forking and merging on bitbucket
For some recent work I was doing with Satchmo's Fedex module, I decided to go through the process of forking on bitbucket with the eventual goal of merging this back into Satchmo tip. Over time, I've had many folks try to fork Satchmo and issue pull request back to bitbucket but some people end up with a bit of a tangled mess. This article covers a basic process for maintaing your fork. -
Django Suite III: Usando virtualenv y pip.
Tercera entrega de la serie sobre Django, esta vez no hablaré del framework en si, sino de un par de herramientas básicas del ecosistema de Python para ayudarnos a ser mas ordenados a la hora de desarrollar proyectos. Virtualenv es una herramienta que nos ayuda a crear ambientes aislados para Python en palabras mas simples instala las bibliotecas e intérprete en una carpeta separada a la de nuestra instalación en el sistema operativo, la ventajas están en que nos provee una manera fácil, rápida, segura y reproducible de hacer desarollo y pruebas de diversas aplicaciones. Por otra parte pipes una herramienta para instalar paquetes de Python desde el Python Package Index que es el repositorio comunitario de paquetes. En conjunto con virtualenv, pip nos ayuda a tener todo organizado y limpio. Usando Virtualenv Primeramente lo instalamos con nuestro manejador de paquetes favorito, en caso de ubuntu el paquete se llama "python-virtualenv" luego procedemos a crear nuestro primer ambiente virtual. virtualenv primer_ambiente --no-site-packages Donde primer_ambiente es el nombre que deseamos ponerle y--no-site-packages es un parámetro para que se cree un ambiente totalmente limpio tal y como fuera una instalación básica de python sin ninguna biblioteca extra. La ejecución de este comando … -
Katie finally talks about her fabfiles
Every time I post about using Fabric, I get the same request: please post my Fabric files. I always intend to, but stop short. Commenter Justin made me realize what had been holding me up. Fab files are usually honed for the style of the developer and project. So, rather than ... -
Introduction to South Migrations
South Migrations are becoming the de-facto standard for those that need to use migrations in Django. They are also very useful as well. This video is an introduction to using south migrations in your projects whether starting a new application or adding it to an existing one. Watch Now... -
Introduction to South Migrations
South Migrations are becoming the de-facto standard for those that need to use migrations in Django. They are also very useful as well. This video is an introduction to using south migrations in your projects whether starting a new application or adding it to an existing one. Watch Now... -
Django Suite III: Usando virtualenv y pip.
Tercera entrega de la serie sobre Django, esta vez no hablaré del framework en si, sino de un par de herramientas básicas del ecosistema de Python para ayudarnos a ser mas ordenados a la hora de desarrollar proyectos. Virtualenv es una … Continue reading →