Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Retiring "SuperJared"
SuperJared.com is moving to LuckyTheTourist.com. -
Release: django-treebeard 1.60
django-treebeard 1.60 has been released (CHANGES). It’s in pypi so you can install it with pip or easy_install. The documentation was also updated, using the graphviz extension for sphinx to generate pretty trees ;) You can get the code in the Mercurial repo. There is also a well maintained Git mirror. Please report bugs in [...] -
Nontrivial Django Forms Talk Text
This is the text from the Nontrivial Django Forms talk I gave last Tuesday at the April meeting of the Ottawa Python Authors Group. This talk starts where the Django forms documentation leaves off. -
Installing Python 2.5 in Fedora 12 for Google App Engine
This stupid install process gets me every time! How do you run Google App Engine which currently requires Python2.5 on a machine that has Python2.6 installed? This also goes for anybody trying to use Django with App-Engine. Everytime I try I get an error like this: Traceback (most recent call last): File "/home/andriy/lib/google_appengine/dev_appserver.py", line 68, in run_file(__file__, globals()) File "/home/andriy/lib/google_appengine/dev_appserver.py", line 64, in run_file execfile(script_path, globals_) File "/home/andriy/lib/google_appengine/google/appengine/tools/dev_appserver_main.py", line 82, in from google.appengine.tools import appcfg File "/home/andriy/lib/google_appengine/google/appengine/tools/appcfg.py", line 59, in from google.appengine.tools import appengine_rpc File "/home/andriy/lib/google_appengine/google/appengine/tools/appengine_rpc.py", line 32, in https_handler = urllib2.HTTPSHandler AttributeError: 'module' object has no attribute 'HTTPSHandler' Now some people say that you need to "compile python with ssl support". But it ain't so. There is actually nothing to configure in the python install to make it include ssl. Python finds the ssl libraries automatically if they are installed. The trick is you need the dev ssl libraries. So here it is for my own reference:Download the openssl-dev packages! Yes... you need them: sudo yum install openssl-dev* Download python2.5 Configure it: ./configure Build it: sudo make Alt-install it to make it reside near your current python install: sudo make altinstall Now download App-Engine and make sure to use … -
Integrating reCAPTCHA with Django
This is how I added reCAPTCHA captchas to TrenchMice, a Django-powered website. Background We didn’t initially build captchas into TrenchMice, because we simply didn’t think they would be necessary. By September 2006, the site started receiving spam comments. They were the usual gibberish you see in blog spam: Lots of links, garbage words, and bogus [...] -
GLAMkit is here!
The Interaction Consortium is proud to release GLAMkit, a free, open source Web framework built on top of Django, specifically for the GLAM (Galleries, Libraries, Archives and Museums) sector. Think Drupal, but but easier, GLAM-specific, with more front-end flexibility, and much better integration with existing databases. The framework is made up of loosely-coupled components, most of which can be used as standalone apps, or as part of a larger GLAMkit ecosystem. Our loosely-coupled design approach makes it easy to integrate GLAMkit functionality into existing Django sites. GLAMkit is currently in alpha development - sign up here to receive announcements about progress. We are still in the process of generalising existing code - so you can expect GLAMkit to grow very quickly over the next few weeks as we plunder our storehouse of code, which represents years of experience and hundreds of hours designing and building GLAM-specific sites. We’d love you to join in on Github or the developers’ mailing list. -
Perfect Deployment Of Websites
Recently I have been giving a lot of thought to how best to deploy websites, specifically Django powered sites. In future posts I’ll describe how I use some of tools available to deploy websites, but in this post I want to set out the goals of any system that you use to deploy a website. [...] -
Django templates not loading?
Had an annoying issue today after upgrading an installation of django to the trunk. All of a sudden, my admin interface would not load. I had errors stating that the template `admin/login.html` could not be loaded. Now, django.contrib.admin was in settings.INSTALLED_APPS, and `django.template.loaders.app_directories.Loader` was in `settings.TEMPLATE_LOADERS`. So, why was django throwing an exception? To find out, I stepped into a shell: {% highlight pycon linenos %} >>> from django.template.loader import find_template_loader >>> loader = find_template_loader('django.template.loaders.app_directories.Loader') >>> loader.load_template('admin/login.html') {% endhighlight %} This was where I realised something was wrong. I don't get the error now (as I have fixed it), but it complained about being not allowed to open the file. As in a permissions error. Looking up the location in a new shell, I was able to see that all of the files in the `django.contrib.admin.templates` directory were only able to be read by root. For some reason, `python setup.py install` had set the mode of these files to _0600_, instead of the expected _0644_. A quick `sudo chmod -r ag+r templates` (from inside the `django.contrib.admin` directory) fixed it. -
Temporary models in Django
Occasionally I need to create a temporary model within a Django application. The most recent occasion for this was a one-off management command I was writing to import some data from a legacy system. The old database, for some reason, eschewed foreign keys in favour of char fields in a linking table which referred to the relevant rows. In converting this to a Django app, and wanting to use sensible database structure, I planned to replace this with normal ForeignKey fields. But I needed to temporarily hold onto the old references during the import process, so that I could set the new FK properly. I didn't want to add a field to my model, create a migration for the new field, do the import, then add another migration to drop the field again, so a quick answer was to create a temporary table to hold the linking data during the import. And I wanted to define it within the management command itself, again so as not to pollute the real models with temporary code. Surprisingly, this turned out to be quite easy. Here's the code: from django.db import models, cursor from django.contrib.contenttypes.management import update_contenttypes from django.core.management import call_command class TempCustomerAddress(models.Model): … -
Temporary models in Django
Occasionally I need to create a temporary model within a Django application. The most recent occasion for this was a one-off management command I was writing to import some data from a legacy system. The old database, for some reason, eschewed foreign keys in favour of char fields in a linking table which referred to the relevant rows. In converting this to a Django app, and wanting to use sensible database structure, I planned to replace this with normal ForeignKey fields. But I needed to temporarily hold onto the old references during the import process, so that I could set the new FK properly. I didn't want to add a field to my model, create a migration for the new field, do the import, then add another migration to drop the field again, so a quick answer was to create a temporary table to hold the linking data during the import. And I wanted to define it within the management command itself, again so as not to pollute the real models with temporary code. Surprisingly, this turned out to be quite easy. Here's the code: from django.db import models, cursor from django.contrib.contenttypes.management import update_contenttypes from django.core.management import call_command class TempCustomerAddress(models.Model): … -
Django Editor - plugin for Eclipse
Django templates (tags, blocks, variables, filters, HTML tags, JavaScript and CSS) syntax coloring support for Eclipse. -
An end to my Evolution
I am stepping down as a maintainer of one of my open source projects - Django Evolution. This shouldn't come as a surprise to anyone - there hasn't been any significant development work done on Evolution in over a year. My personal commitments and my work on Django core are absorbing all my free time at present. As a result, I can't give Evolution the attention it needs or deserves, especially given the changes that will be required to update Evolution to work with Django 1.2. For me, Evolution was always a bit of an experiment. The documentation has always warned that Evolution was not production ready, and the bug tracker would back up that assessment. My aim with Evolution was to demonstrate that a semi-automated migration framework was possible, and to hopefully kickstart a development effort that would ultimately lead to a merge into Django's trunk. In a way, this has happened, just not in the way I intended. Following the release of Evolution, other schema migration projects have been announced -- most notably, South -- and these project provide alternate approaches to the schema migration problem. Some of these projects have been successful, some have not; some have … -
Introduction to Surlex
Introduction to Surlex. A neat drop-in alternative for Django’s regular expression based URL parsing, providing simpler syntax for common path patterns. -
Writing a non-relational Django backend
"The Django ORM is pretty complicated and it takes too much time for contributors to understand all the necessary details. In order to make the process as easy as possible we've implemented a backend template which provides a simple starting point for a new backend based on our simplified API. It also contains sample code, so you can better understand what each function does." by All buttons pressed -
Helping you see what’s happening.
This week we improved the activity views to help you better understand what people are doing on the site. You can see them in action on your dashboard or on any user's profile page like this. We also added a What’s cooking page to share our plans for what we're working on. We'd love to hear your feedback about it! This week’s featured recipe is CT Morrison’s Pasta Dough (With Gluten Free Conversion). She has entire set of gluten-free recipes that are well worth checking out. -
What Is Your Version Of Django
In my professional and personal projects I’ve run into alot of different versions of Django. Out of curiosity can you leave a comment indicating which version of Django you are using? Thanks! -
Writing a non-relational Django backend
In our April 1st post we claimed to have a simplified backend API. Well, this wasn't true, of course, but yesterday it has become true. The Django ORM is pretty complicated and it takes too much time for contributors to understand all the necessary details. In order to make the process as easy as possible we've implemented a backend template which provides a simple starting point for a new backend based on our simplified API. It also contains sample code, so you can better understand what each function does. All places where you have to make changes are marked with "# TODO:" comments. Note, you'll need djangotoolbox which provides the base classes for nonrel backends. Let's start with base.py. You can use the DatabaseCreation class to define a custom data_types mapping from Django's fields to your database types. The types will later be passed to functions which you'll have to implement to convert values from and to the DB (convert_value_from_db() and convert_value_to_db()). If the default values work for you just leave the class untouched. Also, if you want to maintain a DB connection we'd recommend storing it in DatabaseWrapper: class DatabaseWrapper(NonrelDatabaseWrapper): def __init__(self, *args, **kwds): super(DatabaseWrapper, self).__init__(*args, **kwds) ... self.db_connection … -
Retiring Old Posts To Keep Django Fresh
Times change and so does Django, why would this blog be any different. I personally wish more people would do a little spring cleaning here and there. There are few things more frustrating than outdated posts derailing my searches. So to keep it brief here are a few articles that are going away because [...] -
Django-Reporter
This week I finished up the initial release of Django-Reporter, my first open-source project based on work I've done for my full-time employer, Pegasus News. At Pegasus we send daily, weekly, and monthly email reports out to several people. We have a quite complex codebase, so we need these reports to be as flexible as possible. Limitations of the old way Previously, we were creating one-off executable report scripts and collecting them in a directory on the main web server to be hit by cron periodically. This involved a lot of boilerplate code and duplication, and became difficult to manage long-term - especially when we switched from a single-site to a multi-site structure and a lot of the reports broke. Also, we had to include different DJANGO_SETTINGS_MODULE values depending on the site the report was for, and that filled up the crontab with a lot of verbosity. Classes, registration, and a management command My solution was to make the reports class-based, so that we could implement certain methods on each report that handled what makes those reports different while letting the base class handle what stays the same. We subclass the BaseReport class, implement methods for the subject line and … -
Announcing colibri 1.0 alpha1, a mailing list manager with a django based web interface
It has been more than one year now that I’m running my own mailing list software here at freehackers, and I think it is now time to release a first preview of it. Let me introduce Colibri 1.0 alpha1 Colibri is a free software (GPL), based on python and Django. It’s not feature complete, but […] -
Actualitzat vimrc
He actualitzat la meva configuració de .vimrc i els pluggins i ressaltat de sintaxi que hi ha a .vim El subversion: http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/myvim El .vimrc El .vim Novetats Substitució de snipEmu per snipmate. SnipMate fa si fa o no fa el mateix però té una sintaxi més senzilla i clara i permet fer nous snippets molt més fàcilment. He afegit un nou ressaltat de sintaxi per json. El colors per defecte per gvim passa a ser ara wombat i he canvait el tipus de lletra a DejaVu Sans Mono, ja que té una bona distinció entre la vocal O i el zero, entre l'u i la i, bastant millor per programar. Activació per defecte dels menús i de la toolbar a gvim Neteja de la configuració a .vimrc Pos els alias a un fitxer apart dins ~/.vim/abbr, feu alias per veure el que hi ha. Integració de més codi de pycopia especialment dels snippets per Django. 0 comentaris, 0 trackbacks (URL) Automatic translations of this post by Apertium -
Changing the Django Admin site title
Often the Django Admin should look a little different for the sake of your users or for the sake of yourself (running multiple django sites with identical looks and titles can be such a pain). Often users don’t know what Django is, and it takes ages to explain, and even after that they have no clue. Also, often my administration has nothing to do with a website, so I don’t want the text “Site administration”. First of all, you wanna add templates/admin/base_site.html to your project. This file can safely be overwritten, since it’s a file that the django devs have intended for the exact purpose of customizing your admin site a bit. Here’s an example of what to put in the file: {% extends "admin/base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Some Organisation' %}{% endblock %} {% block branding %} <style type="text/css"> #header { /* your style here */ } </style> <h1 id="site-name">{% trans 'Organisation Website' %}</h1> {% endblock %} {% block nav-global %}{% endblock %} This is common practice. But I noticed after this that I was still left with an annoying “Site Administration” on the main admin … -
Testejant Django amb Nose
A poc a poc però sense pausa estic embarcat en la creació d'un motor de reserves orientat cap a hotels i cadenes hoteleres. És a dir, no es tracta de fer un sistema genèric orientat a la integració d'xml com els que poden necessitar agències i TTOO, sinó de tenir quelcom flexible i ràpid de personalitzar orientat a cobrir les necessitats més o manco complexes de la venda directa on line de nits d'hotel. És a dir, el sistema ha de cobrir el bàsic (gestió del nombre d'habitacions disponibles, tarifes, descomptes per ocupació, aturada de vendes, etc) però també ha de permetre cobrir necessitat que en aquests moments no coneixem. Per tant, tenir una bona bateria de tests que ens assegurin que afegint noves característiques no ens estam carregant les que ja hi ha és fonamental. La idea del Test Driven Development és que s'han d'escriure els tests abans d'escriure el codi. Jo no sóc tan purista i els tests els escric quan els necessit, unes vegades abans i unes vegades després d'escriure el codi. La raó és molt senzilla, quan estic immers en l'escriptura de codi per a que passi un test, sovint me trob afegint noves característiques per … -
SimpleDB backend and JOIN support
Update: Did you fall for it? Looks like small lies are more credible. So, there really is no such backend. But if you want to implement one please read our Writing a non-relational Django backend post. As you may have noticed, there were no blog posts in the last three weeks (apart from the one yesterday). We hope the waiting was worth it. We've been busy behind the scenes, working together with Mitchell Garnaat from boto (thanks a lot for the help!) to create a SimpleDB backend for Django nonrel. During that process we also designed a second backend layer which should make writing other non-relational backends much simpler. Basically, all non-relational DBs share some common characteristics, so it would be stupid to make everyone write and understand (!) the complicated code for traversing Django's internal where tree (which represents the query that should be executed). We'll port the App Engine and the (still unfinished) MongoDB backends to that layer later this week. Please contact me if you want to write a backend for the new API. It's mostly a simple Query class which only supports AND and OR rules, but no nested query rules, similar to what PyMongo provides. … -
Running Django admin separately
Django admin is great for administrating a site, but chances are you won't want to run that on your "big serious production site" for a few reasons. Setting up This is pretty easy to do, all your apps will be stored in source control (or something more exotic) so pull those apps down. Leave out the apps you don't need. Perhaps you've got a public facing specific app that pulls in public specific things, sets up context processor or specific auth. backends, all things you don't need in the admin site. This could be set up on the same server, or on a different server as long as it can reach the database. Security There's no limit to the number of password attempts on the admin site. So you could dictionary attack the admin site if you really wanted to get in. Moving it to a separate instance isn't necessarily more secure, unless you set up an appropriate policy. For example: all requests to admin.yoursite.com are internal only, or restricted by IP. Those sorts of policies are very easy for system admins to setup and maintain. Knowing that pretty much no matter what the end user does, they can't access …