Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 … -
Nonrel-search released
Update 2: Post outdated. See the documentation or reference for usage info. Basically you should index your models in a separate file "<app_name>.search_indexes" using the function search.register. This keeps the indexes independent of your models and you don't have to modify your models anymore to make them searchable. Update: SearchIndexField has been removed. In order to index and search your data you have to add a SearchManager to your model definition which takes the same arguments as SearchIndexField before. We are happy to release our first port of gae-search to django-nonrel :) Nonrel-search is a simple full text search engine for nonrelational databases like App Engine using native Django. This is especially useful for users of gae-search which want to switch to django-nonrel. So let's see how to use nonrel-search. Indexing and searching your data In nonrel-search you can make your entities searchable by indexing them. You do so by adding a SearchManager to your model definition: from django.db import models from search.core import SearchManager, porter_stemmer class Post(models.Model): title = models.CharField(max_length=500) content = models.TextField() author = models.CharField(max_length=500) category = models.CharField(max_length=500) rating = models.IntegerField(choices=[(0, 'zero'), (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five'), ], default=0) # index used to … -
Free Software & Linux Days 2010
Free Software & Open Source Days of İstanbul Bilgi University and Linux & Free Software Festival of Linux Users Association are united under the name Free Software & Linux Days this year. If you have attended before, you will probably make no other plans for April 2-3. If you have never been to this event, [...] -
django-bshell
bpython is pretty cool. It gives you an improved python shell, with popups of completeable values. About the only drawback is that some command-line editing doesn't work that well, but I can live with that. I made a django app that provides a new management command: bshell. This will start a new shell, using bpython, and import all of your models. You can get it with: `pip install django-bshell` And then install it into your django settings.INSTALLED apps. The app itself is called 'bshell'. Then you can just use: `django-admin.py bshell` The code can be found on [bitbucket][1]. [1]: http://bitbucket.org/schinckel/django-bpython/ -
get_first_object_or_none shortcut for Django
I will talk about a shortcut I developed for the Django framework and always use in my apps. This code is aimed in making a quik shortcut to obtain the first object of a queryset if it exists or None otherwise. It’s very useful when you want to display the last news in the first [...] -
Announcing django-relationships
I recently posted on writing an app that allows you to create flexible and descriptive relationships between Django's built-in auth.users. django-relationships is the result. -
Adding Views to the Django Admin
I recently had to write a view that had to be contained within the Django admin area, on a separate page from the models. Here's the approach I took. -
South 0.7 Released
After months of hard work, refactoring, blood, sweat, tears, and improvement, South 0.7 is ready.This release has been probably the biggest internal change in South since it first started. We've removed a lot of old code, and significantly refactored the migration-creating code to make it more extensible (as well as not being mostly in one 3000 line file) There are also a few new user-facing changes: New command names.The old startmigration was getting a little overloaded and wasn't too well-named, so it's been split into schemamigration and datamigration commands. There's also a new graphmigrations command, for those with complex dependency sets. No more issues with missing defaults. South realises you need a default for NOT NULL columns now, and prompts you if you forget to specify one as you're making the migration, instead of dying when you try to apply it. Django 1.2 and MultiDB support. As well as supporting the latest and greatest incarnation of the universe's best web framework, 0.7 also has some limited MultiDB support, in the form of a --database option (that works like the option of the same name on the new syncdb command in Django). Custom fields are no longer magically used. Instead, you … -
The Onion Uses Django, And Why It Matters To Us
The Onion Uses Django, And Why It Matters To Us. The Onion ported their main site from PHP and Drupal to Django in three months with a team of four developers, including a full migration of their archived content. Their developers answer questions about the switch in this thread on the Django sub-reddit. -
Django-lawnchair
Lawnchair is a library that provides a client side JSON store and that's really cool. Since I'm going to be using this quite a bit in some of our applications, I started to build out some of the common uses into a library. This makes working with django models on the client side a little bit easier. At the moment django-lawnchair contains a few utilities to do some work on the server, but to be honest, not to much. I'm hoping I can integrate django-piston a bit to make writing that easier. There's a bit more on the client side of things, using django-lawnchair.js you can instantiate a database like this: var todos = new djangochair('/todo/list'); Grabbing all the objects for a model (in this case Todo objects), populating the local database (or whatever backend store you choose) is as simple as: todos.remote_get(add_row); ...as each Todo is added to the DB, the callback add_row will be called. Users can interact with the objects. Each time you change a model in the local DB, we change the state. You can the push all the changed objects to Django: todos.updated(function(r) { todos.remote_save(r); }); This will iterate through each changed object and push … -
New Django Site – The Great British Sleep Survey
I've very recently finished a django based site for a company called Sleepio. -
Creating a ModelForm dynamically
A simple short snippet for creating a ModelForm for an object dynamically. This is a useful library function to validate data and save changes to a model without having to declare a form: from django import forms def model_to_modelform(model): meta = type('Meta', (), { "model":model, }) modelform_class = type('modelform', (forms.ModelForm,), {"Meta": meta}) return modelform_class Based on "So you want a dynamic form". -
More Infrastructure Work
While there isn't much to see right now as a result, a lot of code went out tonight. We've heavily upgraded many underlying bits in preparation for the things to come. We also fixed a couple bugs (recipe export & feedback form related) and made the product suggestions a little more salient. For those uninterested in the details, have a look at the featured recipe of the week from the ever-loveable JonMagic, the very tasty sounding Nick And Toni's Penne Alla Vecchia Bettola. For the technically-inclined, we're now running on what will become Django 1.2. We've also finished ripping out the old tagging infrastructure in favor of the new and we've made the jump to a much more current revision of Basic apps and South. Initial indications look very good to us. Performance is great, the migration process wasn't too involved and there's obviously the gain of some nice features. Most of the pain in upgrading came in updating third-party apps, but even there, there wasn't a whole ton to do beyond our tagging migration. Very positive thus far. -
DevConf::Python() 2010
Какие у вас планы на 17-18ое мая этого года? Пока не знаете? Тогда я могу вам предложить интересное занятие на эти дни. В означенные дни в Москве пройдет первая российская конференция DevConf, которая соберет множество веб-разработчиков из различных "вселенных". Среди прочих вселенных (секций), там будет своя, отдельная, уютная и посвященная Python. Не знаю как вы, а я о чем-то подобном уже давно мечтал. Если вы хотите послушать доклады, поучаствовать в мастер-классах и пообщаться с интересными людми, обменяться опытом и приобрести новые контакты в сообществе, то вы обязательно должны поучаствовать. Регистрация уже открыта, так что не теряйте время и заполняйте форму. Поверьте, такие мероприятия проходят не часто и если вы хотите быть в курсе последних трендов в Python мире, то оно того стоит чтобы поучаствовать. На данный момент мы активно ищем докладчиков и формируем программу. Если у вас есть интересные мысли и желание поделиться ими с сообществом, то регистрируйтесь и предлагайте свои доклады/мастер-классы. Если у вас возникнут какие-то вопросы, то можете смело задавать их мне, т.к. я являюсь членом оргкомитета и отвечаю за питонячью секцию. Call to arms! -
Using Django as a Pass Through Image Proxy
Using Django as a Pass Through Image Proxy (via). Neat idea for running development environments against data copied from a live production site—a static file serving handler which uses a local cache but copies in user-uploaded files from the production site the first time they are requested. -
Hacking on relationships between django's auth.User
Doing a quick search on the Django Developers group for 'user model' yields a bunch of requests for extensible user models. There's also an epic ticket, #3011, opened 3 years ago on this topic. I don't really feel one way or the other about it -- this is just a roundabout way of excusing the hack you're about to see.