Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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. -
Editar y traducir inline en Django fácilmente
Desde Yaco nos traen las aplicaciones pluggables django-inlinetrans y django-inplaceedit que permiten editar traducciones de templates y objetos de nuestros modelos desde el frontend de nuestro proyecto... -
Dropbox file upload handler for django
Dropbox announced new pro plans last week and some accounts have had their storage size doubled. Wouldn't it be wonderful if we could upload all our files to dropbox from our django webapp? In this post, I write a custom file upload handler that will upload files from our application to dropbox. Let us see how to use the custom file upload handler. Install the Dropbox Python SDK before you setup your django app to handle the file uploads. In your settings.py, add the following attributes (with the values filled): DROPBOX_APP_KEY = "" DROPBOX_APP_SECRET_KEY = "" DROPBOX_APP_ACCESS_TOKEN = "" DROPBOX_APP_ACCESS_TOKEN_SECRET = "" # Optional values below # The folder where you want the files uploaded. # Example: /Public or / DROPBOX_FILE_UPLOAD_FOLDER = "" # The value below may be either 'app_folder' or 'dropbox' DROPBOX_ACCESS_TYPE = "" The DROPBOX_APP_KEY and DROPBOX_APP_SECRET_KEY are provided to you when you create a new dropbox app. Fetching the access token and access token secret is outside the scope of this blog post but you can follow the Getting Started Guide until the Get an access token section and then paste the access token key and secret in the DROPBOX_APP_ACCESS_TOKEN and DROPBOX_APP_ACCESS_TOKEN_SECRET attributes respectively. Add the … -
Introduction to Django Selenium Testing
-
Python deployment using fabric and pip
I've spent a not insignificant amount of time working on a deployment function for within my ``fabfile.py`` (the configuration file used by [Fabric](http://fabfile.org)). It's well worth the investment, as being able to deploy with a single command (potentially to many servers) is not only faster, but much less prone to human error. Currently, I'm using [Mercurial](http://mercurial.selenic.com) as my source control. I'm also using it for deployment, but I'd like to get away from that. My deployment process looks something like this: 1. Ensure the local repository has no uncommitted changes. 2. Ensure the ``requirements.txt`` file is exactly the same as the output from ``pip freeze``. 3. Copy our public key to the remote server, for the user ``www-data``, if it is not already installed there. 4. Create a [``virtualenv``](https://pypi.python.org/pypi/virtualenv) in the desired location on the server, if there is not one already there. 5. Ensure ``mercurial`` is installed on the server. 6. Push the local repository to the remote server. This will include any subrepositories. I do a little bit of fancy magic to ensure the remote subrepositories exist. 7. Update the remote server's repository to the same revision as we are at locally. This means we don't necessarily need … -
Go Open Data
What started as a brief conversation between myself and Michael Druker almost a year ago has come to life. On Saturday, May 11th people from Windsor to Ottawa are going to come together at the University of Waterloo School of Pharmacy for GO Open Data, a one day conference. The conference aims to bring together people from across Ontario and across the various interests related to open data to enjoy 8 talks, 2 panels, and an exhibition called Open Data Alley. Citizens, journalists, developers, administrators, CIOs, librarians, different people from all the areas connected to this fusion of technology and policy will be in attendance. That alone will make for an exciting day. It is thanks to the many partners from the Region of Waterloo, the City of Waterloo and the University of Waterloo that such a small idea has become so successful. We have amazing speakers like Ontario Information and Privacy Commissioner Dr. Ann Cavoukian, and up and coming speakers like James McKinney from Open North in Montreal. You can hear an interview with Dr. Cavoukian on the lawful access episode of Jessie Brown's Search Engine podcast. The rest of the schedule can be found online: http://go-opendata.ca/ The conference … -
2.3.6 release
-
A Survey on Software Quality
A Survey on Software Quality Want to help me graduate, and make the software industry a better place for us all? Great! I am writing my graduate report on the topic of software quality, metrics, and visualization. The report will ... -
A Survey on Software Quality
A Survey on Software Quality Want to help me graduate, and make the software industry a better place for us all? Great! I am writing my graduate report on the topic of software quality, metrics, and visualization. The report will ... -
Multi-tenanted Django
TL;DR : I made a thing: [django-multi-schema][django-multi-schema]. As pointed out in the comments, it's now known as [django-boardinghouse][django-boardinghouse]. ## Software, as a Service (SaaS) This is a term that has been around for a while. Basically, providing software that runs on a server, and selling access to that system. Instead of charging people for the software, you charge them a recurring fee for access to the hosted service. If you have more than one customer, then you need to ensure that each customer can only access data that is 'theirs', rather than seeing everything. You need some way to *partition* the data, and there are two main ways to do this. 1. Every customer has their own server/database. 2. All the data is stored in one server/database. ## To each their own. One way of partitioning data is to provision an application server, and a database for each customer. These web servers, and indeed the databases may not even be on different virtual machines, let alone physical machines. I manage a legacy PHP/MySQL application that runs each 'server' as an Apache VirtualHost, shares the codebase, and uses some configuration to route the database connections. The advantages of this type of … -
PAX East 2013
I wanted to write a quick post with some general impressions from my time at the 2013 edition of PAX East. I’ve been attending PAX since 2008, but this was just my second year at the East coast version. I also only went for a single day, which greatly limits the amount of stuff you can see on the convention floor. The venue PAX East is held at the Boston Convention & Exhibition Center, and is the perfect location for this type of event. The building has a ton of space, and can easily handle the number of people that attend. It doesn’t have the wacky charm that the Washington State Convention Center has (the site of PAX Prime), but I’ll take the elbow room over charm any day. The games Battleblock Theater: I first saw this game back at PAX Prime in 2009, before it had a name. I’ve watched it closely since then, following its progression over the years. The game finally released today, and it seems to have benefited from the extra polish. I hope it can captivate me the same way Castle Crashers did, and I look forward to seeing what’s next for The Behemoth. Nutjitsu: … -
PyCon 2013 Recap---Teaching and Learning with the Python Community
Caktus had a wonderful time at this year’s PyCon conference. We believe strongly in supporting our developers in their quest to become the best coders that they can be and think that being at PyCon is a great way for them to learn about what’s going on in the Python community. We sent ten people to the conference to work at our booth and attend conference events. The organizers of PyCon, headed by Jesse Noller, put on an amazing event that created a space for people to meet face to face in order to work and learn together. During the opening keynote presentation, Jesse Noller shared with PyCon his parting gift to the PyCon community before relinquishing the reins after his last year of heading PyCon. He told the audience that the Python Software Foundation was providing a Raspberry Pi computer to each of the 2,500 conference attendees in the hopes that they would build awesome projects and share them widely. This parting gift to the community was part of his contribution to enable pythonistas as he said to, "build a legacy for Python and the community that enriches and enlivens the next generation of programmers" by "infecting everyone with … -
Multi-file find and replace for {% url “quoted” %} tag in Django 1.5
Django 1.5 deprecates the old {% url %} tag style and uses the new one. The new one needs the url name to be quoted. So instead of {% url public_index %} it must be {% url "public_index" %}. You’ll get an error: ‘url’ requires a non-empty first argument. The syntax changed in Django 1.5, see the docs. Instead of adding quotes to each one in each template manually, I wanted a multi-file find and replace regex. Examples abound of using find with xargs and sed. But here’s a simple Python script and example usage to do just that. Note that it updates the files in-place. Make sure you have a backup and/or they’re committed to version control just in case something goes wrong and messes up your templates. You’ve been warned. Here’s a simple find and replace Python script: import sys import os import re def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 4: print """ Usage: %s find replace filename.txt [filename2.txt...] """ % argv[0] exit find = argv[1] replace = argv[2] filepaths = argv[3:] for filepath in filepaths: text = open(filepath).read() #print re.sub(find, replace, text) new_text = re.sub(find, replace, text) if new_text != text: … -
Best practices with Django on WebFaction
This blog post is about deploying Django apps. It is addressed primarily to WebFaction, but applies to any other hosts else with one-click installers for this kind of app. First, many thanks to WebFaction for their great service and support. I've got very few complaints about them in general. However, I think their approach to setting up Django projects is far from ideal, and makes life harder than it needs to be. The WebFaction Django docs tell us to create a new Django app by using the control panel and choosing an app of type ‘Django’ and then choosing your Django version. This will install an Apache instance with mod_wsgi, and a copy of the Django sources, and set up a basic Django app skeleton. There are lots of problems with this: What happens when there is a security issue with Django? The user will need to have an upgrade mechanism. This is covered in the docs, but it is an 11 step process. And this process is a process they will first have to do in their development environment for testing, in some way, and then again on their live box. How many people will actually do that, especially … -
Github test commit reports for teams
I recently wrote githubinfo. It is a quick and handy script that queries the github API of one or more organizations and gives you a simple report on the amount of commits with tests in the last week. I figured it could be useful to others, so I made it available on pypi, including reasonable documentation of course: https://pypi.python.org/pypi/githubinfo . You can pip install githubinfo (or put it in your buildout). It is just a simple single command and the output looks like this: $ testcommitinfo loading project neerslagradar-site loading project ... ... We want more and better testing. For a quick and dirty quantity indication ('more'), here are the commits that have the string 'test' in of of the commit's touched filenames. Period: 8 days. Github organizations that I queried: ddsc, lizardsystem, nens Projects sorted by amount of commits with tests ----------------------------------------------- lizard-neerslagradar: 11 (25%) lizard-progress: 3 (9%) radar: 1 (33%) ... Committers sorted by amount of commits with tests ------------------------------------------------- Reinout van Rees: 12 (11%) Remco Gerlich: 3 (6%) Arjan Verkerk: 2 (8%) ... Goal I wrote it because we wanted to improve our development process at Nelen & Schuurmans. We wanted more tests. So I wrote a … -
Core Concepts of Django Forms
In my opinion, the concepts behind Django's non-model forms can be listed in just three (3) bullets: Forms render HTML. Forms are "just" Python constructs. Forms validate dictionaries (Python's Key/Value structure). Let's dig in! Forms render HTML. If I construct a Django form: # myapp/forms.py from django import forms class MyForm(forms.Form): title = forms.CharField(required=True) I can render it in a template, or for better clarity in this post, the Python REPL: >>> from myapp.forms import MyForm >>> f = MyForm() >>> f <__main__.MyForm object at 0x1016c6990> >>> print(f) <tr><th><label for="id_title">Title:</label></th> <td><input id="id_title" name="title" type="text" /></td></tr> You can even see this done with initial values in the Django docs: https://docs.djangoproject.com/en/1.5/ref/forms/api/#django.forms.Form.initial Forms are "just" Python constructs. I believe it was Alex Gaynor who said back in 2008 that Django forms were "just" Python constructs. He's right: >>> from myapp.forms import MyForm >>> # class >>> MyForm <class 'myapp.forms.MyForm'> >>> # object >>> form = MyForm() >>> form <myapp.forms.MyForm object at 0x1023f1450> >>> # iterable >>> [x for x in form] [<django.forms.forms.BoundField object at 0x102495990>] >>> [x for x in form.fields] ['title'] >>> # dictionary-like >>> form.fields['title'] <django.forms.fields.CharField object at 0x1024a17d0> Understanding the structure of Django forms is really useful. This structure is … -
Core Concepts of Django Forms
In my opinion, the concepts behind Django's non-model forms can be listed in just three (3) bullets: Forms render HTML. Forms are "just" Python constructs. Forms validate dictionaries (Python's Key/Value structure). Let's dig in! Forms render HTML. If I construct a Django form: # myapp/forms.py from django import forms class MyForm(forms.Form): title = forms.CharField(required=True) I can render it in a template, or for better clarity in this post, the Python REPL: >>> from myapp.forms import MyForm >>> f = MyForm() >>> f <__main__.MyForm object at 0x1016c6990> >>> print(f) <tr><th><label for="id_title">Title:</label></th> <td><input id="id_title" name="title" type="text" /></td></tr> You can even see this done with initial values in the Django docs: https://docs.djangoproject.com/en/1.5/ref/forms/api/#django.forms.Form.initial Forms are "just" Python constructs. I believe it was Alex Gaynor who said back in 2008 that Django forms were "just" Python constructs. He's right: >>> from myapp.forms import MyForm >>> # class >>> MyForm <class 'myapp.forms.MyForm'> >>> # object >>> form = MyForm() >>> form <myapp.forms.MyForm object at 0x1023f1450> >>> # iterable >>> [x for x in form] [<django.forms.forms.BoundField object at 0x102495990>] >>> [x for x in form.fields] ['title'] >>> # dictionary-like >>> form.fields['title'] <django.forms.fields.CharField object at 0x1024a17d0> Understanding the structure of Django forms is really useful. This structure is … -
Now it's your turn
I just watched Jacob's talk on "Porting Django apps to Python 3", and realised it was time to tackle my own small Django apps. The problem with porting is that you need your dependencies to be ported first. But now that Django has Python 3 support, the finger is no longer pointing at Django — it is pointing at all of us with Django apps that have only Django as a dependency (or other dependencies that are already ported to Python 3). As Jacob put it at the end of the talk, it’s your turn. So, I took the challenge, and here is a walk through of what you need to do, and what I had to do: Find an app/library you've written that has very few dependencies, or all dependencies already ported to Python 3. In my case, django-easyfilters. Not a massively popular library, but it has had over 1000 downloads, and I know some people use it. Install tox and create a tox.ini file to run your test suite on more than one version. Start with all the Django versions you want to support, with Python 2.x combinations (Python 2.6 and 2.7 recommended), and Python 3.3. My tox.ini … -
Mails amb Django - IV
Amb tot el que hem vist fins ara podem organitzar els nostres enviaments de correus i mantenir al seu manteniment organitzat encara que el nombre d'opcions sigui gran. Hi ha encara un grapat d'escenaris que és interessant tractar, ja que ens els trobarem sovint. Pensem en aquests possibles escenaris: Ens hem de connectar a un servidor SMTP extern i el temps de connexió és gran, la qual cosa fa que la nostra aplicació web no respongui. Tenim un entorn de preproducció on els correus no s'enviïn però on volem mantenir registre del que s'hauria enviat. Volem mantenir un registre dels correus que s'envien dins la nostra aplicació. El primer escenari es pot resoldre amb un servidor de correu local y fent realy cap al servidor final, però això a vegades no és possible ja que no tenim la gestió del servidor de correu. També ho podem resoldre amb un sistema de coes, és a dir, l'enviament de correu es posa com a tasca i és un altre programa (un worker) el que se n'encarrega de fer l'enviament. La combinació de Celery+Redis ens pot anar bé, però també estam afegint un factor gran de complexitat: hem de tenir Redis instal·lat, configurar … -
Getting AngularJS Authentication Working with Django
django-angular-auth is a very simple example app or seed to get AngularJS authenticating using Django and Tastypie. Although AngularJS' documentation has gotten much better, it still took me quite a while to figure out what exactly was the best path to take. Also, there are a few gotchas with allowed headers and cross-site security which are already solved in the example. Take a look and let me know what you think.