Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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. -
Using Django as a Pass Through Image Proxy
An earlier post shows you how to setup Nginx as a pass through image proxy. This post shows you how to do it with just Django and nothing else. The Problem We've solving the same problem as the earlier post. However, I will repeat it here for clarity as there's been some confusion. You have a production DB with lots of images uploaded by users. For example, NationalGeographic.com has over 11gb of user uploaded images. When you download a data dump of the production database, it has links to all these images which you don't have. You either have to download and sync all the images locally every time you copy the database, live with broken images or point your static images to the prod server. Copying images locally is the brute force method and will work. If you have all day to sync up images. Pointing to the images in prod also works, but if you upload your own images to test functionality... You will not be able to see those new images. You have a prod site with gigabytes and gigabytes of user generated static content. Whenever the database from production is copied to some lesser environment, like … -
Writing a custom field in Django
Reusable code is one of the most talked-about silver bullets in our toolkit. Django has a huge ecosystem of reusable apps, but not nearly so many reusable fields. Apps and fields generally solve different problems, though, and while an app can be retemplated or modified to fit your use case, a field is often times so specialized or exact in its purpose that either you need it or you don't. In this entry I'll discuss a great use-case for a field we had at work building out live March Madness coverage, and a popular field that is also an app. -
1950s
Mine is Johnny Depp, unchallenged. But I’m not into celebrities very much. Download 1950s movies -
What’s New in django-formfieldset 1.1
I have just released 1.1 version of django-formfieldset. I has been almost a year since version 1.0. Here is a summary of changes for this version: New Example Project There is a new and improved example project. It is designed to be some sort of documentation at the same time. When you run the example [...] -
Largest open-source Django project
Thierry Schellenbach from YouTellMe.nl recently wrote on his blog that their site is probably the largest Django project in terms of codebase. Since their project isn’t open-source, it’s hard to tell if that claim is true or not. But it got me wondering. What is the largest open-source Django-based project around? Some times ago I already posted some ‘source lines of code’ (SLoCs) metrics about the Peach³ Django project (41209 at the time). But is SLoCs the best way to define which project is the largest? Or maybe we should use some more ‘Django-based’ metrics, like number of unique apps (22 for Peach³) or number of models (86)? Or maybe the largest project is the project with the most people using it on a day-to-day basis (approximately 350 for Peach³ at the moment). And, using any of these metrics, what would be the largest Django-based open-source project around at the moment? I could not find any metrics of any other projects. I feel Peach³ might actually be one of the bigger projects out there, but I have nothing to base that feeling on. -
Tagging overhaul and some downtime
We experienced a half-hour of downtime just a little bit ago while rolling out an overhaul to our tagging system. While downtime is never fun, it means that we've fixed some lingering issues with our tagging system. Our original tagging system had some problems handling tags with spaces and that should be fixed now. For the geeks in the house, this means that we've moved away from django-tagging and to django-taggit. If you see anything out of order, please let us know by sending a quick note using the feedback box at the bottom of every page. -
Rails and Django commands : comparison and conversion
The most commonly used Rails commands and their Django equivalents Rails Django rails console manage.py shell rails server manage.py runserver rake None rails generate None rails dbconsole manage.py dbshell rails app_name django-admin.py startproject/manage.py startapp rake db:create manage.py syncdb The salient points to note are, Django has all commands via manage.py, Rails has it broken into [...] Related posts:Django for a Rails Developer The Rails and Django models layer Rosseta stone -
Django based startup – YouTellMe.nl
YouTellMe.nl is a completely Django based startup located in Amsterdam. We’re probably one of the largest Django projects in terms of codebase. Pretty soon the famous nextweb awards are coming up. (remember those guys which broke into Michael Arrington’s house?). And we need some love from the Django community. Lots of it. Pretty please nominate youtellme.nl for the next web! http://dsa.thenextweb.com/?lang=nl Good articles coming soon to offset the bad karma for this shameless plug ;) Update: A couple of stats about the current codebase. According to wc (including whitespace and comments) we currently have: Python: 3,363,188 characters, 87926 lines, 655 files Javascript: 940,536 characters, 24229 lines, 77 files Share and Enjoy: -
South 0.7 RC1
It's that time of the year again, when a new South release rears its well-refactored, database-independent head.If you've been following the development of South at all, you'll know that 0.7 has been quite a while in the making. I've been busy working away at a big code refactor, along with Simon Law, who has gained the title of "Knowing Too Much About Migrations". However, there are some user-facing changes as well, some quite significant. While my release notes go into some detail on what's new, the major changes include: 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. 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 … -
Django query analyzer
One of the things I wanted to work on at the DjangoSki sprints was a django query analyzer. The basic premise is that I want to create an easy way for users to experiment with and play with the ORM to produce the queries that they want. If you are new to Django, figuring out the ORM is one the first things you will need to tackle and it can be a little opaque. There's some ways to play with it at the shell, or use the debug toolbar, but these can be a little limited and unhelpful to newbies. The main interface would ideally be a series of options introspected from the model. Choose a model, choose a query manager, then add in multiple filter queries. This would not be able to capture everything and you'd always need an opt out clause of a text area where you can enter anything you want. This is pretty similar to the GUI's you'll get with most SQL servers, its just the Django ORM layer on top of it. Sadly I didn't get much chance apart from some time on Thursday afternoon. But a whole bunch of other people did including Stefan …