Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Aptana Studio and “Undefined variable from import: DoesNotExist”
Teaching Aptana Studio about DoesNotExist -
Falsehoods Programmers Believe About Names
Falsehoods Programmers Believe About Names. People’s names are complicated. I’m not at all comfortable with the commonly used first name / last name distinction (as baked in to Django auth) since it doesn’t take cultural factors in to account. -
Quick shell command to add CSRF token
To get the benefit of Django 1.2's new CSRF protection, all POST forms will need a special token. Here is a quick command that runs through templates adding the token: find . -type f -name "*.html" -exec sed -i \ 's|\(<form[^>]*method="post"[^>]*>\)\({% csrf_token %}\)\?|\1{% csrf_token %}|g' \ {} \; -
Using Fabric For Deployment
In a previous post I discussed what you want from an automatic deployment system. In this post I’ll discuss how use to solve the repeatability and scalability requirements that I set out. Fabric is a tool which lets you write scripts to automate repetitive tasks. So far, so bash like. What sets Fabric apart is [...] -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
The syncbox
I move between a couple different computers regularly: my old 12" PowerBook and the 15" MacBook Pro my job provides me with. Like all multi-computer users I periodically bump up against the challenges of what files (and versions) are where, especially when there's work in progress. To further complicate things, I also have an extra laptop running Ubuntu. And sometimes I just SSH to my web server from somebody else's machine. I spent a while thinking about solutions. Some people keep a "master" home directory on a server, using rsync to pull new copies (or freshen old copies) on machines where they work. Being an rsync fan, I tried this approach. After my first accidental rsync --delete casualty, though, I started thinking about ways to preserve history. That's when the ideal solution hit me (making a big resonant "DUH" sound): distributed version control. Perfect synchronization: check. Multi-platform clients: check. Full history: check. I created a Mercurial repository on my web server, then cloned it out to the two laptops. For stuff that needs to be secure, I decided that simple command-line encryption was the answer (hence this tweet from a while back with a Blowfish encrypt/decrypt one-liner). And I use … -
Migració a postgres des de sqlite
Pels qui no ho sabíeu aquest blog corria damunt una base de dades sqlite3. La base de dades és prou ràpida per les necessitats d'un blog com aquest, però té un emperò considerable: consumeix molta memòria comparada amb un mysql o postgresql. Quan el blog duia una parell de setmanes amb visites que consultàven molts apunts, sqlite començava a cachejar i el consum de memòria de l'aplicació del blog es disparava fins als 160 Mb, mass si ho comparam amb altres aplicacions tant o més complexes que executant-se amb Postgresql estàven entre 30 i 50 Mb. El consum de Postgres és una altra cosa, però com que es reparteix millor entre les aplicacions el resultat final és un estalvi de memòria. El procés per passar d'sqlite3 a Postgres ha estat el següent: Feim un dump de les dades cap a json. Això es pot fer des de Django amb la comanda dumpdata, per exemple: python manage.py dumpdata contenttypes > dumps/contenttypes.json He fet dumps de sites, auth per la part d'usuaris, contenttypes, i després de tota la resta d'aplicacions que fa servir el blog. Cream la base de dades i l'usuari a Postgresql que farem servir, donant-li permisos de creació de … -
Lately
I have really gotten out of the habit of blogging and I hate that. It's not because I don't have anything to talk about. Quite the contrary -- a lot has been going on. I thought today would be a good chance to provide a recap of things I have been doing and thinking. StudioNow / AOL Back in January, the startup I have been working on since very close to it's beginning three, well almost four years ago now, was acquired by AOL. This has been the single best experience of my career. To build something from scratch that didn't exist before with a group of really smart folks and turn it into something valuable enough for someone else to purchase at a multiple that made everyone involved happy. I started off not knowing anything about Python, about ffmpeg, about video on the web, much less anything to do with cloud computing. Looking back at what we have accomplished technically, and I wouldn't have thought it possible or likely been able to fully grasp when first starting. I am now close to 6 months on the other side of the acquisition as a full time employee of AOL. I … -
Lately
I have really gotten out of the habit of blogging and I hate that. It's not because I don't have anything to talk about. Quite the contrary -- a lot has been going on. I thought today would be a good chance to provide a recap of things I have been doing and thinking. StudioNow / AOL Back in January, the startup I have been working on since very close to it's beginning three, well almost four years ago now, was acquired by AOL. This has been the single best experience of my career. To build something from scratch that didn't exist before with a group of really smart folks and turn it into something valuable enough for someone else to purchase at a multiple that made everyone involved happy. I started off not knowing anything about Python, about ffmpeg, about video on the web, much less anything to do with cloud computing. Looking back at what we have accomplished technically, and I wouldn't have thought it possible or likely been able to fully grasp when first starting. I am now close to 6 months on the other side of the acquisition as a full time employee of AOL. I … -
GSOC status report
I’ve been behind on the Summer of Code work. This week I started working on converting model tests, and converted 3 changes. I also submitted a patch clarifying the documentation (and help text) of the dumpdata command. I’ve been going more slowly than I should because I’ve had to read a lot of documentation about [...] -
Gracious E-Mail Bounce Handling in Django with Postmark
When a user signs up on your website with an invalid email address, how do you let them know? In most cases, the bounces go into the inbox of an admin who ignores them, or even worse they don't go into any monitored inbox. Recently I've started using a 3rd party for my email delivery, which has made dealing with bounced emails much easier both for me and my customers. Read on to see how I integrated Postmark's bounce API with Django, and implemented a user-friendly alert on DjangoSites.org when signup emails bounce. -
Gracious E-Mail Bounce Handling in Django with Postmark
Recently I've been on a quest to simplify the way I deliver my websites to my customers. Not that my customers know: the primary changes are relating to server monitoring, being proactive about a few things, and getting rid of elements that I don't understand. One of the things I really didn't understand that well and wanted to offload to somebody else was my email delivery. I already use a company called Tuffmail to handle my mailboxes (that is, for my actual email boxes - not email sent from within my Django applications) and I'm extremely happy with their service. I use and trust Tuffmail because I know I can't keep on top of everything I need to know to run SMTP and IMAP services properly and securely. The next step in my outsourcing process was to find a company to deliver email sent from within my Django applications. Until now I've been running a local Postfix server used for delivering mail but not receiving it, and for most emails that works fine. As websites grow, though, it becomes harder to manage what happens with bounced email and also to guarantee delivery - many email providers seem more than happy … -
Gracious E-Mail Bounce Handling in Django with Postmark
Recently I've been on a quest to simplify the way I deliver my websites to my customers. Not that my customers know: the primary changes are relating to server monitoring, being proactive about a few things, and getting rid of elements that I don't understand. One of the things I … -
Optimizing for Shared Hosting
Shared hosting, no matter how their packages are painted, have limits. Staying away from hogging too much CPU, memory, and other resources can ensure the longevity and performance of your shared hosting account. If you are just looking into how to build a site, or if you already have a very busy site on shared hosting, these guidelines can help you get the most out of your shared hosting account before making the switch to more expensive hosting. One of the goals in this post is to encourage "good neighbor" practices that will ensure you aren't disrupting fellow users on the server that hosts your account. This also ensures that you won't get any of these principles also apply to other types of hosting, but this is written with shared hosting in mind. Common bottlenecks With modern shared hosting, you generally have plenty of available disk space and bandwidth. The most common bottlenecks encountered by a site in shared hosting are CPU and databases. Memory usage is a less common bottleneck, but it can happen depending on how well or how poorly your site's code is written. On-the-fly page generation takes quite a bit of CPU compared to serving flat … -
Backwards compatibility
Backwards compatibility is pain sometimes: # We need backwards compatibility with code which spells it this way: # def my_view(): pass # my_view = cache_page(my_view, 123) # and this way: # my_view = cache_page(123)(my_view) # and this: # my_view = cache_page(my_view, 123, key_prefix="foo") # and this: # my_view = cache_page(123, key_prefix="foo")(my_view) # and possibly this way (?): # my_view = cache_page(123, my_view) -
Django 1.2.1 lançado
Django 1.2.1 lançado -
Django 1.2.1 lançado
Django 1.2.1 lançado -
Taskqueues in App Engine
App Engine has task queues as an experimental feature. There's nothing fancy here, it's just a way of queueing something up to be run later. We've probably all written a few queues in our time, the task queue is just a continuation of that. Add a URL to be executed a certain point and a scheduler will come along and try all the urls in the queue. For Arecibo we use this to do the post processing on an error. When an error comes into Arecibo we write it to the datastore quickly, we then add in one task queue that will: figure out the grouping, figure out any notifications, figure out the user agent (surprisingly a bit expensive). That post processing will be done async via the task. First thing that I noticed about the queue is that the development server doesn't run the task queue automatically meaning that all my unit tests failed. So here's a way to do it immediately if you are not in production: if os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'): # send the signal, otherwise we have to clicking buttons # to process the queue send_signal(None, self.id) else: # enqueue the send notification # if development taskqueue.add(url=reverse("error-created", args=[self.id,])) … -
util
D’oh: django/contrib/admin/util.py django/contrib/admindocs/utils.py django/contrib/comments/views/utils.py django/contrib/formtools/utils.py django/contrib/gis/db/backends/util.py django/contrib/gis/tests/utils.py django/contrib/localflavor/it/util.py django/contrib/localflavor/se/utils.py django/contrib/localflavor/uy/util.py django/contrib/messages/utils.py django/core/files/utils.py django/core/mail/utils.py django/db/backends/util.py django/db/utils.py django/forms/util.py django/http/utils.py django/test/utils.py tests/regressiontests/forms/util.py -
Expanded services, portfolio, and more in the new Caktus web site
We're pleased to announce the release of the latest and greatest Caktus web presence yet. This edition features an enhanced services section and portfolio. Among other things, the new site demonstrates how our Django-based content management system can be used to connect related pages in customized, innovative ways. -
Creating a Cacti Alternative
I want to replace cacti. I love graphs and information collation as much as the next guy, but I want something more and at the same time, something much less. I have recently finished my second year of a Computer Science course at the University of Nottingham, and thus it is time to start thinking [...] -
An inline image Django template filter
Adding image fields to a Django model is easy, thanks to the built-in ImageField class. Auto-resizing uploaded images is also a breeze, courtesy of sorl-thumbnail and its forks/variants. But what about embedding resized images inline within text content? This is a very common use case for bloggers, and it's a final step that seems to be missing in Django at the moment. Having recently migrated this site over from Drupal, my old blog posts had inline images embedded using image assist. Images could be inserted into an arbitrary spot within a text field by entering a token, with a syntax of [img_assist nid=123 ... ]. I wanted to be able to continue embedding images in roughly the same fashion, using a syntax as closely matching the old one as possible. So, I've written a simple template filter that parses a text block for tokens with a syntax of [thumbnail image-identifier], and that replaces every such token with the image matching the given identifier, resized according to a pre-determined width and height (by sorl-thumbnail), and formatted as an image tag with a caption underneath. The code for the filter is below.