Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Resources for Django on WebFaction
It feels like forever ago that patrickbeeson.com and a few of my other sites were hosted on Dreamhost. That is, of course, an increasingly distant memory now that I'm served by WebFaction's nearly fire-proof boxes. But making a Django environment stable wasn't as turn-key as their marketing might lead you to suspect (though it's easier than Dreamhost). In an effort to help future WebFaction Djangonauts, here are some most-read posts from WebFaction's excellent user-forum and knowledgebase. Domain transfer Note: WebFaction doesn't handle domain registration. You'll need to change your name servers to those used by WebFaction. Mine are still on Dreamhost. How can I add a new domain to my account? Apache configuration How do I stop/start/restart my Django Apache instance? How to fix errors like: ImportError: No module named django.core.management How do I serve static content? Running multiple Django sites from the same Apache/mod_python instance Django configuration Serving the Django admin media directly from the main Apache server How do I run the latest Django trunk? Cron + Django Script For Newbies - deploying your Django app Running "manage.py syncdb" Using Robots.txt file under Django in WebFaction Sending e-mails from Django Deploying A Django Application Memory usage Note: If … -
'Practical' tips for working with Django
Everything I did building the content management system for this Web site was wrong. Actually, that might be an overstatement since this Web site works quite well (better than it did in Movable Type). But in the course of building a new Django content management system (CMS) that will drive the new, soon-to-be-launched Young Professionals of Knoxville Web site, I've learned a lot of useful techniques. Much of my new-found knowledge is due to Django Release Manager James Bennett's wonderful book "Practical Django Projects." Custom managers One of the critical needs for the new YPK site is the posting and display of events. At first, I figured this would require a standard model with the following fields: slug name location (ForeignKey to Location subclass) description event date start time finish time attire (With two options: formal and casual) category (ForeignKey to Category app) But then I realized that I would need a way to filter out events that are no longer current -- who wants to view old events? That's where custom mangers in models come into play: class CurrentManager(models.Manager): def get_query_set(self): return super(CurrentManager, self).get_query_set().filter(event_date__gte=datetime.date.today()) This allows me to filter all events whose date is greater than or equal to … -
How Django is good for SEO
Django, the venerable Python framework created for the publishing needs of a newspaper Web site, is surprisingly good for organic search engine optimization (SEO). In fact, Django comes with many options out-of-the-box that sets it apart from other means of building Web applications. These include: beautiful URLs, a plethora of database options, sitemap framework and elegant template design. Beautiful URLs Compare an URL from most any Django Web site to those of an ASP or PHP site, and you'll notice a big difference: You can read the Django URL. And that's good for you and Google since it's factored into the page's importance. Here's an example of URLs captured from two newspaper Web sites, the first using Django: Knoxnews.com (Django): http://www.knoxnews.com/news/2008/jul/22/storms-fell-trees-cut-power/ Startrib.com: http://www.startribune.com/local/stpaul/25971699.html Some PHP sites come close to Django's beautiful URLs: News-record.com (PHP/Drupal): http://www.news-record.com/content/2008/07/21/article/superintendent_finalists_have_nc_connections But what makes Django's URLs extra nice is the ease at which you can create them. To design URLs in Django, you need only create a Python module called URLconf. This serves as a "table of contents for your app," according to the official Django documentation. Here is an example of what a sample news site's URLconf looks like (taken from Django documentation): from django.conf.urls.defaults … -
YPKnox.com: Knoxville's newest Django site
The launch of the redesigned and retooled Young Professionals of Knoxville Web site brings yet another Django site online for the city of the Sunsphere. It also marks my third Django project -- the others being this site and Knox'd -- since I began learning the vaunted Python framework nearly two years ago. What I learned Building the new YPK Web site was a challenge in several ways. Here are some specific problems I encountered: How to filter out expired events in specific views, but make the permalinks available for bookmarks and search engines. How to only show "live" press releases, as opposed to press releases being edited. How to pass in more objects into generic views. How to improve the site performance by writing more efficient database queries and text-to-HTML rendering. The solutions for these problems were documented in a previous blog entry titled "'Practical' tips for working with Django." Also, I must again credit James Bennett for publishing his wonderful book Practical Django Projects without which I would probably still be hunting down information (or bugging the developers at work). Site features The new YPK Web site isn't that extraordinary. But it does feature some useful ways of … -
How to create user-specific admins in Django
The newForms admin branch of Django officially landed in trunk a few weeks ago. Not only does this allow for the awesome django.contrib.admin application to be more customizable, it also solves handily a problem I ran into for an upcoming project: Creating a user-specific Django admin where users see only the objects they create. Project intentions My latest Django project involves creating a basic content management system (CMS) that I can use as a hands-on example for a journalism class I'm teaching at The University of Tennessee this fall. The class, Managing Newspaper Web sites, will cover basic concepts for managing a modern newsroom where a CMS is a vital part of the publishing process. One assignment, for example, will require students to take a story written for print, and edit it for the Web as they enter it into a CMS. To accomplish this goal, I plan to build a basic models for stories, categories and photos that I hope will emulate those in Ellington, the Django-based CMS used by newspaper Web sites owned by Scripps (my employer). Other requirements But unlike Ellingon, where anyone with the proper access can see everyone else's stories, I don't want students to … -
How to upgrade to Django Comments 1.0
The release of Django 1.0 held many new developments for the Python-based framework that I've used to build several projects during the past few months. But one feature I was really looking forward to exploring was the new, refactored comments application. Unfortunately, Django Comments 1.0 also comes with the scary prospect of database updates, data migrations, markup changes, CSS changes and other headaches. Here's how I tackled the now-documented upgrade for this application. Prepare your projects My personal Web site was already running on a variation of Django trunk (pre-alpha) before I upgraded to Django 1.0 final. This made the update process somewhat easier since I'd already been through the updates for newForms admin and the like. Also, I don't have a typical development environment for this site, which really puts an emphasis on reading through the documentation. You don't want surprises from backwards-incompatible changes! Here are the steps I took for preparing my site for Django Comments 1.0: Read the documentation on the Django Project site thoroughly (including the upgrade guide) Comment out, or remove any references to the awesome, but incompatible (for now) django-comment-utils package Change any reference to "FreeComment" to "Comment" Change template tags to reflect the … -
Medill's News Mixer remixes story comments
The Knight Foundation grant-backed graduate program at Medill's School of Journalism has birthed what could be a game-changing effort for news story comments. Their effort, called News Mixer, leverages traditional news content, Facebook's Connect feature and offers three methods of user feedback: Questions and answers: Allows a reader to leave a question about the story, and allows other readers, including the reporter, to leave an answer. Quips: A short-answer, or Twitter-like format that allows you to offer a quick response, limited to 140 characters. Letters to the editor: An outlet for readers to send their thoughts in 250 words or less, whether about an article, another letter someone wrote, or on any subject the author deems important. An editor can then select and highlight the best letters. But what's unique about News Mixer is how it uses these three types of functionality to channel user comments in a more meaningful way. Why News Mixer is different Traditional Web story comments are wrought with problems, especially when editors and content producers are hands-off in their management style. This style of commenting usually consists of a form located at the end of a story or content and contains the following components: Name … -
How to stop spam on a Django blog
Don't rely on the honey pot to attract, and hold at bay, spam comments for your Django blog. Stopping spam completely for a blog built using Django takes a three-pronged approach of Akismet, date-based closing of comments and a cron-run script that removes spam comments from your database. And fortunately, all three steps are quite easy to implement. Note: I'm using Python 2.5 and Django 1.0.2 Install and enable Akismet The best front-line defense for stopping spam to your Django blog is to use Akismet via the Python API. Here are the steps: First, download akismet.py and put it on your PYTHONPATH. Then get a Akismet API key by signing up for a free Wordpress blog. Put the API key in the apikey.txt located in your Akismet directory. You'll also need to add the URL for your blog. Add this line to your Django project settings.py: AKISMET_API_KEY = '<your_api_key>' Open up your blog models.py and add the following code snippet (this will also enable e-mail notification for new, public comments): from django.contrib.comments.signals import comment_was_posted from django.utils.encoding import smart_str from django.core.mail import mail_managers import akismet from django.conf import settings from django.contrib.sites.models import Site ... def moderate_comment(sender, comment, request, **kwargs): ak = … -
RSS feed for comments on a Django blog entry
Django makes it possible to have an RSS feed for everything. Of course, possible is not always easy. Sometimes it just takes a little logic, documentation and the help of programmers much smarter than I to get things done. In this case, it means building an RSS feed for comments on individual entries on my Django blog. Prerequisites I'm using Django 1.0.2 and the contrib comments and syndication applications for this example. Creating the feed The first thing I'd recommend is checking out the Django Project documentation for creating a complex feed. This will show you how to derive objects related to another object (comments for an entry). My Django blog models.py is pretty basic: class Entry(models.Model): # Status options CLOSED_STATUS = 1 EDITING_STATUS = 2 LIVE_STATUS = 3 STATUS_CHOICES = ( (CLOSED_STATUS, 'Closed'), (EDITING_STATUS, 'Editing'), (LIVE_STATUS, 'Public'), ) # Title and slug fields title = models.CharField(max_length=200, help_text='This field will populate the slug field. Maximum 200 characters.') slug = models.SlugField(unique_for_date='pub_date') # Summary and body fields summary = models.TextField(help_text='Please use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.') body = models.TextField(help_text='Please use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.') # Markdown conversion for summary and body fields summary_html = models.TextField(editable=False, blank=True) body_html = models.TextField(editable=False, blank=True) # Tag field tags = … -
Stack Overflow a boon to stuck developers
Developing web applications is a little like learning how to ollie a skateboard. You try, and try, and try. Then you try again. And then something clicks. You land the trick. But you don't understand why. This has been my experience writing code. I know what I want to do, and through brute force I hammer away at a solution until something works. But why does it work? That's where Stack Overflow and it's wonderful community comes in. Let me be clear: I'm no computer scientist. I have a diverse background that includes public relations and journalism in addition to web development. But I know HTML, CSS and JavaScript very well. This trifecta led me into higher-level development languages like Python, and the wonderful framework Django a few years ago. Perhaps it's my tenacious journalist attitude that keeps my head beating against the wall in an attempt to solve problems. Whatever it is, I'm thankful there exists helpful communities on the web. Stack Overflow is a question and answer website where developers of any language can pose a mud-pit scenario from which they can't seem to escape. If the question is well-crafted, and tagged appropriately, answers glom like flies on … -
Retrocompatibilitat
Aquesta setmana m'he trobat en una situació on pots veure la diferència entre fer feina amb un llenguatges com Python i un bastiment com a Django, vers fer-ho amb altres tipus de bastiments (sí Rails, t'estic parlant a tu) amb distinta filosofia de feina i de com s'han de fer les actualitzacions. Rails i Django són cosins germans. Els dos van intententant agafar el millor que té l'altre. Permeten desenvolupar aplicacions web amb molta rapidesa i són molt divertits per fer-hi feina. La gran diferència és en la filosofia de feina: Django i Python tenen força cura en la compatibilitat cap enrera, en que a cada versió hi pugui haver canvis, però que siguin de tal manera que en la seva gran majoria les aplicacions segueixin funcionant amb modificacions mínimes. Rais i Ruby, per la seva banda tenen un historial de anar trencant amb tot el que hi ha a cada versío. El més important és la novetat, en la màgia del que es pot fer, en el factor sorpresa per tal de deixar la claca bocabadada. Però què passa quan el que tens són aplicacions que s'han de mantenir al llarg de molts anys? Com deia aquesta és una … -
On TRUCEConf
Yesterday brought news of TRUCEConf. It’s a terrible, dangerous and insulting idea. The organizers should reconsider, either canceling the event or changing its scope and mission radically. I have no doubts that the organizers have good intentions, but good intention don’t always yield positive results. As is, TRUCEConf’s very existence runs counter to the vision of equality in tech. Tone arguments and trivialization It’s hard to read the verbiage on TRUCEConf‘s home page as anything other than an extended tone argument. -
Sentry on Riak
Over the course of getsentry.com, one thing has become abundantly clear: you can never have too much disk space. In 20 months it’s been running, we’ve doubled our disk consumption six times. This may not sound like a big deal, but we’ve always tried to be tight on expenses, and it … -
Sentry on Riak
Over the course of getsentry.com, one thing has become abundantly clear: you can never have too much disk space. In the 20 months it's been running, we've doubled our disk consumption six times. This may not sound like a big deal, but we've always tried to be tight on expenses, and it... -
Sentry on Riak
Over the course of getsentry.com, one thing has become abundantly clear: you can never have too much disk space. In the 20 months it’s been running, we’ve doubled our disk consumption six times. This may not sound like a big deal, but we’ve always tried to be tight on expenses, and it gets even m... -
Release of Colibri 1.0-beta2
Time flies, and I haven’t made any release of Colibri for a long time, despite it being used in production and bug being fixed as they are found. So here it is. No shiny new feature there, it’s mostly about bug fixing, code cleaning and updating the code. More importantly: Colibri now requires Django 1.6, […] -
We Don't Know All The Things
Our guest this week is Laura Cassell, software engineer/instructor at Big Nerd Ranch and founder of Pyladies Atlanta! -
My First Django Sprint
This year I attended my first DjangoCon and, needless to say, it was pretty amazing. I also attended my first Django Sprint after DjangoCon was over. It was a fantastic opportunity to work alongside some of the members of the core team and to learn more about how decisions are ... -
Using strace to Debug Stuck Celery Tasks
Celery is a great tool for background task processing in Django. We use it in a lot of the custom web apps we build at Caktus, and it's quickly becoming the standard for all variety of task scheduling work loads, from simple to highly complex. Although rarely, sometimes a Celery worker may stop processing tasks and appear completely hung. In other words, issuing a restart command (through Supervisor) or kill (from the command line) doesn't immediately restart or shutdown the process. This can particularly be an issue in cases where you have a queue setup with only one worker (e.g., to avoid processing any of the tasks in this queue simultaneously), because then none of the new tasks in the queue will get processed. In these cases you may find yourself resorting to manually calling kill -9 <pid> on the process to get the queue started back up again. We recently ran into this issue at Caktus, and in our case the stuck worker process wasn't processing any new tasks and wasn't showing any CPU activity in top. That seemed a bit odd, so I thought I'd make an attempt to discover what that process was actually doing at the … -
Upload Files
Learn how to use Django to let your users upload files. This uses only what is built into Django to get you started.Watch Now... -
ShipIt Day 4: SaltStack, Front-end Exploration, and Django Core
Last week everyone at Caktus stepped away from client work for a day and a half to focus on learning and experimenting. This was our fourth ShipIt day at Caktus, our first being almost exactly a year ago. Each time we all learn a ton, not only by diving head first into something new, but also by hearing the experiences of everyone else on the team. DevOps: Provisioning with SaltStack & LXC+Vagrant We have found SaltStack to be useful in provisioning servers. It is a Python based tool for spinning up and configuring servers with all of the services that are needed to run your web application. This work is a natural progression from the previous work that we have done at Caktus in deploying code in a consistent way to servers. SaltStack really shines with larger more complicated systems designed for high availability (HA) and scaling where each service runs on its own server. Salt will make sure that the setup is reproducible. This is often important while testing ideas for HA and scaling. The typical cycle looks like: Work on states in Salt Run Salt through Fabric building the whole system, locally through vagrant, on a cloud provider, … -
django-nomad-notifier
We have been busy lately working on some projects (still under development) that required a notification system for the different events triggered by the users activity. You know, the kind of notifications from your favorite social networks for things like "Congratulations ! You have unblocked a new bagde" or "User Slothie is now following you", usually received via email and also displayed on the site itself. For this we released, a few weeks ago, a new Django app called django-nomad-notifier: https://github.com/Nomadblue/django-nomad-notifier Do not expect a typical "batteries included" project, in fact it is really the opposite. But we are trying here to provide a nice documentation (the "usage" section) to guide any user to make good use of the idea behind this: http://django-nomad-notifier.readthedocs.org/en/latest/ As usual, comments, pull requests, forks, etc, are welcome! -
Death Defying Lifelines
Our guest this week is Clinton Blackburn, photographer, aerial silks person, and software engineer for Kyruus in Cambridge, Mass. -
Django Extensions notnull_differ
Django Extensions SQLDiff command is looking for somebody with MySQL skills to help out. In the GIT version of Django-Extensions we improved support for detecting NOT NULL changes in database. However this is currently only implemented for SQLite and PostgreSQL. We would like for the MySQL support to not lag behind the other backends. So are you using MySQL and have 30 mins to an hour to spare ? Then consider helping out and add notnull_differ support for MySQL to SQLDiff :) Link to get started: https://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/commands/sqldiff.py#L506 -
Our Python 3 migration status
IP Street’s application runs on Python 2.7. Earlier this week, I evaluated all our Python packages for Python 3 support, as the first step in deciding when to migrate our codebase. Although this was the time I’ve checked our packages for Python 3 support, I expected Django to be the only one that didn’t officially support it. (Production support is slated for version 1.6, which is now in release-candidate.) But Django is the only project whose development roadmap I closely follow! D’oh! Talk about a blind spot!! This is why it’s good to sit down and formally check each package. Make a list of every package and check each one… Of the 29 packages we use, 20 (69%) support Python 3 and nine (31%) do not. I was really surprised by two of the non-Python 3 packages. The nine packages are: django. Python 3 support was “experimental” in version 1.5, and is production-quality in version 1.6, which is imminent. django-guardian. The documentation doesn’t explicitly say “supported in Python 3.” OTOH, it has closed Python 3 tickets, is under active development, and Django 1.6 is just over the horizon. I’m guessing/hoping this supports Python 3 shortly after Django 1.6 releases. django-mobile. …