Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 … -
Caktus Consulting Group hosts 2nd Django sprint in NC Triangle area
Django is a tool we use every day to build fantastic web apps here at Caktus, and a development sprint is a concerted, focused period of time in which developers meet in the same space to get things done on a project. -
Maintain Constants.py through Data Migration
This post will show you how to create a local_contants.py file using Django South. If you're not familiar with South, it's a data migration tool. Stated differently, it's a tool that helps keep your database changes current across different sandboxes and server environments. The reason you may want to have constants is when you have a type model instance that you want to reference in your code for decision logic. For example, you might display things differently if your contact method type ID is 1 (email) vs 2 (phone). Typically, you keep these in constants.py file. Although sometimes you can put this data in a fixture, for various reasons sometimes fixtures is not the ideal solution. The code below is designed to be run inside a migration to update your local_constants.py file with data that you just migrated. local_constants.py is a locally maintained file. This means, that like your local_settings.py, it should not be in the repo. For example: set_constant('/home/projects/sample/local_constants.py', 'STAMP_MW_ID', 42 , 'Set from sample.0007_add_constants.py') The constant searching could be improved, feel free to post enhancements! def set_constant(file, constant, value, comment = ''): ''' Search through file for the constant and either adds it to the end or updates … -
Configuring Nginx as a Pass Through Image Proxy
This post shows how to setup Nginx has a pass-through image proxy server. This is useful for local sandboxes, UAT and QA servers where you copy production database down to but don't want to copy all the user generated images to the non production environment. The problem You have a production database 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 DB, 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. Solution Setup nginx to look for static images locally and if it doesn't find it, go to the production server and pull the image. This works nicely because you can upload images … -
2Ze.us Updates
There has been quite a bit of recent activity in my 2ze.us project since I first released it nearly a year ago. My intent was not to become a competitor with bit.ly, is.gd, or anyone else in the URL-shortening arena. I created the site as a way for me to learn more about Google's AppEngine. It didn't take very long to get it up and running, and it seemed to work fairly well. AppEngine and Extensions I was able to basically leave the site alone on AppEngine for several months--through about September 2009. In that time, I came up with a Firefox extension to make its use more convenient. The extension allows you to quickly get a shortened URL for the page you're currently looking at, and a couple of context menu items let you get a short URL for things like specific images on a page. Also included in the extension is a preview for 2ze.us links. The preview can tell you the title and domain of the link's target. It can tell you how much smaller the 2ze.us URL is compared to the full URL. Finally, it displays how many times that particular 2ze.us link has been clicked. … -
On Security and Python's Exec
A recent project at work has renewed my aversion to Python's exec statement--particularly when you want to use it with arbitrary, untrusted code. The project requirements necessitated the use of exec, so I got to do some interesting experiments with it. I've got a few friends who, until I slapped some sense into them, were seemingly big fans of exec (in Django projects, even...). This article is for them and others in the same boat. Take this example: #!/usr/bin/env python import sys dirname = '/usr/lib/python2.6/site-packages' print dirname, 'in path?', (dirname in sys.path) exec """import sys dirname = '/usr/lib/python2.6/site-packages' print 'In exec path?', (dirname in sys.path) sys.path.remove(dirname) print 'In exec path?', (dirname in sys.path)""" print dirname, 'in path?', (dirname in sys.path) Take a second and examine what the script is doing. Done? Great... So, the script first makes sure that a very critical directory is in my PYTHONPATH: /usr/lib/python2.6/site-packages. This is the directory where all of the awesome Python packages, like PIL, lxml, and dozens of others, reside. This is where Python will look for such packages when I try to import and use them in my programs. Next, a little Python snippet is executed using exec. Let's say this snippet … -
Pip pip hurra!
Què voleu, estic content de veure que una eina com pip funciona tan bé. Pip és una eina per a la instal·lació de paquets i dependències per Python, molt més avançada que easy_install ja que permet tot el que feia easy_install però a més, permet mantenir d'una manera fàcil un arxius amb totes les dependències del nostre projecte. Ens permet instal·lar paquests de Python des dels repositoris de Pypi, des de subversion, git, mercurial a través d'un fitxer de requeriments simple i a la vegada funcional. Mode batalleta on: Ahir vespre estava fent feina amb un projecte mascota que tinc, un motor de reserves per hotels i cadenes hoteleres fet amb Python i Django. El projecte necessita de força llibreries: la darrera versió de django, nose pels tests, sphinx per la documentació, django debug toolbar, django extensions, south per la migració de dades, ipython, ipdb, pep8, coverage, pytlint. Tot això (i algunes més que s'hi afegiran) constitueixen l'entorn de desnvolupament del projecte. Actualment faig feina amb tres ordinadors: el fix (el PPC del que tant he parlat per aquí), portàtil un Dell D820 i un Dell de 10". Segons on estic i el que he de fer en faig servir … -
Updates for django-lastfm and django-sphinxdoc
After reading The Hitchhiker’s Guide to Packaging I update my packages for django-lastfm and django-sphinxdoc. There are no functionional improvements, so you don’t need to update them.