Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django Pattern for Reporting Errors/Messages in Views Part 2: Managers
In my last post, I discussed how you can use a simple UserMessage class in your views to report simple error messages. This way, you can keep track of errors and report them to the users in a clean fashion. One thing I didn't expand upon much is how to create some manager methods to cleanly lookup model instances and report any errors to the UserMessage class. I think this approach is a little nicer than catching exceptions all over the place, because you don't have to clutter your views with try/catch blocks.In the example below, we create a custom manager that looks up a model instance of "MyModel" with the given hash. If the selected instance of "MyModel" does not exist or if some other error occurs, it writes an error message to "message" instance passed into it. You can customize this as you see fit. For example, in the code below, I pass in a "user" instance that can be used to check permissions in this method. class MyModelManager(models.Manager): # In this case, we pass in a user, a unique hash for a # "MyModel" object instance, and an optional message. def get_mymodel(self, user, mymodel_hash, message=None): mymodel = [] … -
Git-based Django deployment
If you ever used Heroku (or any similar service), you may be jealous of their straightforward way to deploy new versions of applications. At least, I am. That's why I came up with a couple of hacks to mimic their git-based deployment workflow, but for my own Django applications, served by Gunicorn. The basic idea is: your application code is contained in a Git repository, and your production deployments are as simple as a git push. Note: because we will type commands on both the client and server side, server-side commands will start by a > and client-side commands by a $. All commands are executed by a regular user. Table of contents » Prepare your serverCreate your simple Django applicationThe deployment scriptTweak your production git repositoryUnleash the green unicornAdd your changes to the production repositoryGo further Prepare your server » First of all, let's prepare the ground by installing all the software we need on our production server (for the record, I used a Lucid Vagrant box): Now that we have the software, let's create the base structure for our production website. In my configuration, I'm in my home, which is /home/vagrant/. The var directory will contain the pidfile … -
The Buddha Website Nominated for Webby Award
I'm delighted to announce that the PBS companion website for The Buddha — a site that Caktus helped build using the Django web framework — has been nominated for a Webby Award in the Religion and Spirituality category! Online voting for the People’s Voice awards is now underway and we would appreciate you voting for the site ... -
Django & postgres & SSL
I’d thought something like this is a FAQ but the db docs on postgres don’t write a bit about forcing Django to connect using SSL to the database server. After lots of googling (and finding hundreds of guides how to set up a Django with HTTPS) and finding out by try-and-error, behold the solution: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'dbname', 'USER': 'dbuser', 'PASSWORD': 'dbpassword', 'HOST': 'dbhost', 'OPTIONS': { 'sslmode': 'require', }, }, } -
Read the Docs Update
It's been a while since I last talked about Read the Docs, and there has been a lot of activity. This is an update on the latest and greatest new features. PSF Funding The biggest news that has happened is that we have been given a grant from the Python Software Foundation to help host the site. Thanks PSF! They have blogged about it, and I am grateful that they have given us support. With the funds they have offered, we have been able to make Read the Docs a lot faster, and more robust. I will outline some of the changes below. This also means we won't be going away any time soon! New Theme We have a fancy new theme for documentation on Read the Docs! If you have the 'default' theme for your project, it will show up on the build of your docs on the site. I think it is pretty great, thanks to the designers who spent their time making it awesome. A really great feature is that the new theme is mobile ready. Go ahead and view a project using it on your phone, or make your browser smaller and you will see the … -
Configuration stuff
-
Configuration stuff
I’ve had several thoughts on configuration lately. I take no credit for any of them. There will never ever be a size that fits everything. Or even anything. Ini, XML, SQL, Python (for configuration) and “format-agnostic” APIs are all the same limited-if-mandatory things. Usage of a format which can’t be edited by humans directly (or almost directly, like a SQL database) is making a huge problem for users. Usage of a format which can’t be edited by programs directly is making a huge problem for users. If your program wants to be configured before usage, you need some kind of not mandatory interactive process of doing this.1 If your program wants to be configured before usage, and your interative process of configuration is mandatory, scary, slow, uses either only GUI or only CLI, can lead to odd results or break everything, this process is wrong. Config files are good. And if your program can just talk to user about what to put in there in his partical case, your program is lovely. So we need good libraries for talking with user about how he wants to configure stuff. And these libraries can’t even try to make assumptions about how developer … -
Giving back to the community.
As part of the most recent work I’ve been doing with the project I’ve been spending a lot of time digging around and getting familiar with Django’s HttpRequest, WSGIRequest and MultiPartParser objects. One of the new changes in Django 1.3 … Continue reading → -
A Guide to Testing in Django
A Guide to Testing in Django -
Magic! Python! Django! Whee!
This blog is now run by Django. I didn’t really like Wordpress which I used before. And also I don’t like PHP anymore (I really liked it some years ago, but everything changed, when I learned Python …). When I told a friend that I wanted to switch from Wordpress to something else, he just said: «Use Django.» So I took a look at the Tutorial and was instantly thrilled. At first, I wanted to use an existing weblog app, but I also wanted to code an app for my own and since I din’t find a weblog app that I 100% liked, I just decided to write my own. So here it is (far from finished though)! Features so far: Basic post model (title, slug, pub date, modify date, status, category, HTML body) Post manager for post counts (per year, month, category (and tag)) Hierarchical category model – imho, this is the highlight of my app. Archive and Categories Some special template tags. Usage of a recursive template tag for the categories Unit- and doctests for the models and template tags Features to come: Comments Atom feeds Sidebar Static pages Trac integration for my projects Search Last.fm sidebar widget … -
Are you looking for Python and Django Work?
I've done some consulting work for a company in New York City that is looking for full time developers of all levels. They've got a solid business model, experienced and excellent leadership, and an existing team of talented developers who do things the right way. The founders and developers have been behind a bunch of things you know and love. The company is stable, well-financed, and offers full benefits.In short: they're building the dream team. They don't use dumb words like rockstar and ninja: they're looking for quietly competent developers with a taste for travel.Additional experience with CSS, JavaScript/JQuery, GIS, Git, Linux, and experience with contributing to open source projects are definite pluses.Before you apply you need to pass this little test of mine. If you fail any portion of of this test then we won't consider hiring you.Can you get to the office or are you willing to move closer? When you begin, you need to be able to get to New York City, New York every day of the week. Over time you can work out telecommuting options. Are you a solitary developer? I'll throw away any responses from recruiters and consulting firms.Bonus Question: Not a requirement but do … -
Finding which python packages are out-of-date
As your projects get bigger, they collect more and more packages. It can be a chore keeping track of which packages have been updated to fix potential bugs. We have that issue and devised a simple script to tells us which installed packages could use a bit of freshening up. You’re using pip, right? First off, this only works with pip. pip has a freeze command that lists all the installed packages. pip also understands virtualenv isolation environments, so it can list just the packages in the current virtualenv. Multiple index support Many of our packages are on PyPI, but every now and then we need to host a package on our own package index. We have an instance of chishop running for our index. We had to add XML-RPC support for this script to work (as of release 0.4.3 these additions have been merged back in). So the script needed to support multiple indexes and find the newest version between all of them. Calling the script If you execute the script without any arguments, it will default to searching PyPI. If you pass space-delimited URLs it will use those instead. For example we would call it: $ python check_for_updates.py http://opensource.washingtontimes.com/pypi/ http://pypi.python.org/pypi to search both PyPI and … -
We're hiring!
UPDATE: I completely forgot to update this post until now, but we have filled this position. We're looking for a full time developer. If you're reading this you probably know what we do, so you'll obviously need to know Django pretty well. Knowledge of PostgreSQL and devops skills are a big plus. We would prefer if you lived in Lawrence, Kansas, obviously, but a few visits here may be fine. Only because we get lonely. Lawrence is an awesome town, so don't let the surroundings (the rest of Kansas) scare you off. It's the hometown of Django and basketball. People often compare it to a smaller version of Austin or Portland, OR. For example, check out the local music happening this weekend on the great Lawrence.com. Interested? Email frank@revsys.com with your resume and code samples. Links to public repositories are ideal, also feel free to talk yourself up with respect to Open Source contributions. Docs, code, answering questions on a mailing list, your StackOverflow account, etc. are all good things to bring to our attention. We probably shouldn't need to tell you this, but if you've contributed code to Django you might want to lead with that! -
Mercurial mirror for Django stable branch 1.3
Django recently released the 1.3 version, and as such a new ‘stable’ branch was created in subversion. As I did for the 1.2 branch, there’s now a mercurial mirror, following the 1.3 branch. It is updated every (european) night. The 1.2 mirror is not removed, it is still running and maintained. The url for this [...] -
Fossgis: geodata-infrastructure and web mapping with geonode - Andreas Hocevar
Gathering data is expensive. Gathered data is worthless. Making data available is relatively cheap. Available data is valuable. So: having data available on the web is good. Keeping your data safe in some sort of data-cemetary isn't that useful. If you have to make a map, normally you'd break out your desktop GIS system. You'd get your own data and download external data and convert it. You'd do analysis and in the end make a map. The alternative is to do everything on the web. Not everything that is possible on the desktop GIS is possible/feasible on the web. Analysis, for instance, is more limited on the web. But you don't need to convert/import external data as that's assumed to be available on the web. Geonode (build with GeoServer, Django, and GeoExt) is a tool you can use for pure web-based GIS. You can upload and manage GIS data. They're big on metadata: you don't want just a dumping ground. Maps are an important content type. Maps combine the data/layers and the styles. Geonode allows many people to collaborate. For every user, you can see the data layers and the maps that he added. For every data layer, you can … -
Fossgis: geodata-infrastructure and web mapping with geonode - Andreas Hocevar
Gathering data is expensive. Gathered data is worthless. Making data available is relatively cheap. Available data is valuable. So: having data available on the web is good. Keeping your data safe in some sort of data-cemetary isn't that useful. If you have to make a map, normally you'd break out your desktop GIS system. You'd get your own data and download external data and convert it. You'd do analysis and in the end make a map. The alternative is to do everything on the web. Not everything that is possible on the desktop GIS is possible/feasible on the web. Analysis, for instance, is more limited on the web. But you don't need to convert/import external data as that's assumed to be available on the web. Geonode (build with GeoServer, Django, and GeoExt) is a tool you can use for pure web-based GIS. You can upload and manage GIS data. They're big on metadata: you don't want just a dumping ground. Maps are an important content type. Maps combine the data/layers and the styles. Geonode allows many people to collaborate. For every user, you can see the data layers and the maps that he added. For every data layer, you can … -
Writing a spider with a django-powered web interface
I'd been scrounging around for a smallish project, when I happened on the idea of writing a spider with a simple web interface. I had recently released a task queue, so I wanted to incorporate that to do the actual crawling, while a django view served up the results as they arrived in the database. The end result is a new project I'm calling django-spider, you can check it out on GitHub. This post will discuss some of the aspects of the design. -
Python Packages sprint on Sunday 4/10/2011
Want to help Python? Want to encourage PyPI to focus on being the best package index system possible and not a catalog/ratings/documentation engine? Then sprint with us on Packaginator this weekend because...We need your help!In my last blog post I mentioned Packaginator which will power the forthcoming Python Packages site. The purpose of this site is to do for Python what Django Packages does for Django. We aren't quite ready for launch, and the purpose of this post is to list what tasks remains. There is an enormous amount of outstanding work, and we want to launch as soon as possible so...Before I begin, Python Packages will have some dramatic differences from Django Packages:The 'Add Package' controls won't exist. The only way to get a package into the site is to put your package onto PyPI.At launch only approved moderators will be able to create new grids and grid features.Only approved moderators and package owners will be able to edit the target repo URLs and add/edit/remove packages on grids.Users will still be able to click the "I use this" button. Please join us!We invite you to sprint with us on Sunday, April 10, 2011. We are sprinting on Python Packages / … -
Creating a .pth file
An easy way to add packages to the Python path without actually adding them to the dist / site packages is by using a pth file. All you have to do is create a new file inside of the dist / site packages folder and give it a /pth extension like this: django.pth In that file you can add the path to your Django package like this: /var/src/Django-1.2.3 The advantage of doing this is that you can keep... -
Creating a .pth file
Creating a .pth file -
PyCon 2011 Sprint Report
I love sprints. I've yet to participate in a sprint where I didn't learn something that made a difference in my programming career. Off the top of my head some of the things I've learned include distributed version control, picking the right Python tool, JQuery, SQLAlchemy, Bazaar, Git, Mercurial, the true importance of unittests, and Python's built-in zip function. And the PyCon 2011 sprints were no different.PyCon 2011 was different in that this time I was going to co-lead a project, specifically Django Packages and the hopeful launch of Python Packages.Note: The goal of Python Packages is not to replace PyPI, but rather serve as a resource to find, evaluate, and compare packages used in the every day life of a Python. In my opinion, PyPI should be dedicated to listing and serving packages - anything else (comments, ratings, documentation, etc) just adds complexity to the project and diffuses the focus of their team.It all started with us being the second-to-last in line at the PyCon sprint announcements. At the microphone I forgot to mention a few things so I was worried that our attendance would suck. I tried to take it in good humor, but doubt worried at my … -
Cross-domain quirks in IE8
-
Django howto: Non-conflicting slugs
A while ago I was testing a Django project at work. In the project we had a Django app called Groups. To create a group, you should point the browser to www.domain.tld/group/create/ and to view a group, you had to point your browser to www.domain.tld/group/<group_slug>/. Of course a group slug is unique, so we should never have any conflicts. That is, until I decided to create a group with the slug 'create'.As expected, I was faced by the 'Create a new group'-page when I tried to view my pretty new group. When I swapped some URLs in de Groups app, everybody who tried to create a new group, was served the page of my beautiful group. Everything worked as expected, but still it was considered a bug. This was not the kind of functionality the customer was looking for. For the time being we just let it be (what are the chances the customer would create a group with the slug 'create'?), but the case kept whining in the back of my head.Until today. I decided to tackle the problem. And of course, it was easier than I thought.After entering some smart queries, Google told me that there is something … -
The penguin who owns example.com
Episode 1 of Scared of Rabbits. I feel sad for this poor little bird. Permalink | Leave a comment » -
Setting Up Your Own PyPi Server