Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
The missing documentation for django.utils.datastructures
Note django.utils.datastructures is intentionally not documented by the django core devs because it is an internal API and is liable to change without any notice. This file is not governed by django's lenient backwards-compatible policy. You have been sufficiently warned! With the note out of the way, let's look at the interesting datastructures in this file. You may ask why we should learn about those when we shouldn't be using them? Reading code is the best way of learning and this file has some beautiful code. MergeDict is the first of the datastructures in the file. It provides a dictionary like interface but can look up from multiple dictionaries provided during the initialization. Here's an example: >>> md = MergeDict({"foo": "bar", "moo": "cow"}, {"abc": "def"}) >>> md["foo"] 'bar' >>> md["abc"] 'def' >>> md.get("abc") 'def' >>> md["xyz"] KeyError: >>> md.items() [('foo', 'bar'), ('moo', 'cow'), ('abc', 'def')] >>> md.keys() ['foo', 'moo', 'abc'] >>> md.values() ['bar', 'cow', 'def'] The MergeDict is used within django in attaching values with a form widget and in request.REQUEST. The built-in dictionary does not maintain the order of the items but the SortedDict is a subclass of the built-in dictionary that maintains the keys in exactly the same … -
django-scribbler, a lightweight front-end interface for Django template editing
django-scribbler is a new open-source project published by the team at Caktus. Its goal is to create a seamless way for authorized end users to make edits to specific blocks of content in their Django template. The original project idea came from a conversation Mark and I had about a front end editor Mark was working on. His original idea included a toggled area on the page where users could preview the changes to the content. I suggested it would be even better by showing the user their changes as they were making them. That inspiration came from Bret Victor's talk on “Inventing on Principle”. In his talk, he explains that creators need and “immediate connection to what they create.” To create this effect of seeing your edits as they happen, the developer defines blocks in the template that can be edited by the end user on the front end. Once logged in, that user is able to hover over those blocks and edit as they see fit. The user immediately can see their changes. When they are ready, they can save changes to the database or even save as a draft. During Caktus's Inaugural ShipIt Day, Mark and I … -
My vagrant setup on OSX
I said in using vagrant for developing on OSX: why? that I chose vagrant for setting up my development environment. Now it's time for some specifics. Vagrant box setup and location Per virtual machine, vagrant uses a directory with a Vagrantfile in it. As a convention, I place my vagrant directories as subdirectory inside ~/vm/. The name of the subdirectory (I'll use "django" as an example in this blog post) is the name I use for the virtual machine. So ~/vm/django/Vagrantfile is the vagrant file for my "django" virtual machine. I have one other ("barebones"), but I already know I'm also going to make a "php" one for three mysql/php sites that I sometimes do a bit of work on. Those end up in ~/vm/php/ and so. Everything that's not in git (/svn/hg/bzr) doesn't exist, so I've versioned my ~/vm/ directory. I ignore (.gitignore) the django/php/barebones directories. The Vagrantfiles in those directories are symlinks to ~/vm/vagrantfile_django and so on. There's a README.txt to help me set it all up when I move to a new computer. I also have a fabfile for setting up the (django) box automatically. Some of the things the fabfile does: Install a couple of extra … -
Evennia changes to BSD license
As of today, Evennia changes to use the very permissive BSD license. Now, our previous "Artistic License" was also very friendly. One main feature was that it made sure that changes people made to the core Evennia library (i.e. not the game-specific files) were also made available for possible inclusion upstream. A good notion perhaps, but the licensing text was also quite long and it was clear some newcomers parsed it as more restrictive than it actually was.... And let's be honest, it's not like I would have come hunting down anyone not complying fully with the Artistic license's terms. Changing to the much simpler and more well-known BSD license better clarifies the actual licensing situation.After all, far too many older MUD-code bases are weighted by a legacy of licensing issues. Anything we can do to avoid this is better in the long run. Indeed we hope this change in licensing will remove eventual licensing doubts for new adopters and have more people join and contribute to the project. -
Mercurial Mirror For Django 1.5 branch
Django has just released the first alpha for the next big release, 1.5. As such they created the 1.5.x branch that will lead to the 1.5.0 release and then will become the stable branch. I do not intend to use the 1.5 branch before the final release, but I’ve already setup the mirror nonetheless. The mirror […] -
Easily Add Stripe Payments to your Django Site
Earlier today I blogged over on Eldarion's site about how you can easily add Stripe payments to your website with a new app that we have developed and open-sourced under the BSD license.Be sure to check it out! -
Django Extensions 1.0.0
So it finally happened, Django-Extensions 1.0 is out. After getting a lot of feedback from the community, I decided to call it 1.0. Discussions about going fully on-par with Django on version numbering was very interesting and the nice thing about a 1.0 release is that we can always do that later. For now having 1.0 is good enough and besides if we would have called it 1.4 now we never would have been able to celebrate the 1.0 release ;) Please all start testing this release so we can iron out any small issues left as soon as possible. Some highlights of the changes in this release are: new validate_templates, Checks templates for errors. sqldiff: PostgreSQL HStore support runserver_plus: Django 1.4 WSGI_APPLICATION support runserver_plus: add --print-sql option dumpscript; several improvements shell_plus: added support for ipython notebook shell_plus: added --print-sql option mail_debug: several improvments Using Travis-CI now in combination with GitHub Several fixed for Django 1.4 -
Simple Site Checker and the User-Agent header
Preface: Nine months ago(I can’t believe it was that long) I created a script called Simple Site Checker to ease the check of sitemaps for broken links. The script code if publicly available at Github. Yesterday(now when I finally found time to finish this post it must be “A few weeks ago”) I decided to run it again on this website and nothing happened – no errors, no warning, nothing. Setting the output level to DEBUG showed the following message “Loading sitemap …” and exited. Here the fault was mine, I have missed a corner case in the error catching mechanism i.e. when the sitemap URL returns something different from “200 OK” or “500 internal server error”. Just a few second and the mistake was fix. Problem and Solution: I ran the script again and what a surprise the sitemap URL was returning “403 Forbidden”. At the same time the sitemap was perfectly accessible via my browser. After some thinking I remembered about that some security plugins block the access to the website if there is not User-Agent header supplied. The reason for this is to block the access of simple script. In my case even an empty User-Agent did … -
Marcus: двуязычный блог
Ещё в январе я тихо заменил здесь WordPress на самописный блог. Публично это отразилось разве что в двух твитах, и никакого поста я про это не написал. Отчасти из-за лени, отчасти от того, что всё там было довольно банально. Один из плюсов собственного блогософта в том, что к нему можно прикручивать новые фичи именно в таком виде, в котором хочется. И после реализации в блоге двуязычности, я посчитал, что стоит сделать небольшой технический обзор. Сразу скажу, что я не планировал блог, как коробочное приложение. И хотя написан он в автономном стиле, он, всё же, достаточно своеобразен и вряд ли подойдёт по фичам большинству блогеров. Код Код можно смотреть в бранче на Launchpad'е. Его получилось немного — около 860 строк, и он, как по мне, хорошо читается. Интересно, что примерно 250 строк из всех ушло как раз на двуязычность. Впрочем, строчек непосредственно в коде блога получилось так немного, потому что много чего вынесено в библиотеки: pingdjack используется для рассылки и приёма pingback'ов scipio с его антиспам-конвейером заведует авторизацией по OpenID в комментариях subhub реализует персональный PSHB-хаб, благодаря чему посты мгновенно появляются в яндексовом Поиске по блогам и, следовательно, Подписках — новом воплощении старой Я.Ленты. Фичи Ничего экстраординарного блог собой не представляет. … -
Marcus: двуязычный блог
Ещё в январе я тихо заменил здесь WordPress на самописный блог. Публично это отразилось разве что в двух твитах, и никакого поста я про это не написал. Отчасти из-за лени, отчасти от того, что всё там было довольно банально. Один из плюсов собственного блогософта в том, что к нему можно прикручивать новые фичи именно в таком виде, в котором хочется. И после реализации в блоге двуязычности, я посчитал, что стоит сделать небольшой технический обзор. Сразу скажу, что я не планировал блог, как коробочное приложение. И хотя написан он в автономном стиле, он, всё же, достаточно своеобразен и вряд ли подойдёт по фичам большинству блогеров. Код Код можно смотреть в бранче на Launchpad'е. Его получилось немного — около 860 строк, и он, как по мне, хорошо читается. Интересно, что примерно 250 строк из всех ушло как раз на двуязычность. Впрочем, строчек непосредственно в коде блога получилось так немного, потому что много чего вынесено в библиотеки: pingdjack используется для рассылки и приёма pingback'ов scipio с его антиспам-конвейером заведует авторизацией по OpenID в комментариях subhub реализует персональный PSHB-хаб, благодаря чему посты мгновенно появляются в яндексовом Поиске по блогам и, следовательно, Подписках — новом воплощении старой Я.Ленты. Фичи Ничего экстраординарного блог собой не представляет. … -
JQuery Sortables + AJAX + Django = fun
Like my other code posts, this one starts with a problem (or an opportunity). How do I integrate jQuery Sortable with Django? The use case was designing a slideshow and I wanted users to be able to sort slides and pull them from the "active" column to the "inactive" column. Heck, While we're at it, how about being able to drag to a trashcan? Honestly, I'm not the greatest with javascript. But I'm persistent. If you haven't tried it, jsFiddle is an awesome workspace for developing javascript code. You can quickly make changes and see what happens in seconds. For those of you who are impatient and don't want to scroll to the example at the bottom, here is my fiddle for this code. Here's the general game plan for accomplishing this. I'm going to let the code speak for itself for the details, it should be pretty straightforward to read. create 3 separate lists: active, inactive, trash use a common class for slides pass the PK of the slide in the 'id' attribute make each list sortable and connect them to each other in the 'update' event, send the (active|inactive|trash) PKs via POST to the server in the 'receive' … -
Django GetOrCreateView
Today I decided to use the Django class based view (CBV) CreateView, but I wanted to avoid duplications and submit to the view from the front page of a site. The reason was I needed a simple newsletter signup form. This is what I cooked up and should work for Django 1.3, 1.4, and the forthcoming 1.5 release. Here is what I did: 1. Installed dependencies This version requires the following package to be pip installed into your virtualenv. django-extensions so we can have easy timestamps on models. This also needs to be added to your list of INSTALLED_APPS: INSTALLED_APPS += ( 'django_extensions', ) 2. Defined the model The model is really simple, and inherits from TimeStampedModel so we know when people signed up: from django.db import models from django_extensions.db.models import TimeStampedModel class NewsLetterSignup(TimeStampedModel): email = models.EmailField("Email") def __unicode__(self): return self.email 3. Wrote the view Here's the somewhat challenging part that forced me to dive into Django's source code. Even with the documentation work we've done over the past few months, it's clear we've got a long way to go. Because of that source code diving, for this blog post I really did my best to document why I did … -
Django GetOrCreateView
Today I decided to use the Django class based view (CBV) CreateView, but I wanted to avoid duplications and submit to the view from the front page of a site. The reason was I needed a simple newsletter signup form. This is what I cooked up and should work for Django 1.3, 1.4, and the forthcoming 1.5 release. Here is what I did: 1. Installed dependencies This version requires the following package to be pip installed into your virtualenv. django-extensions so we can have easy timestamps on models. This also needs to be added to your list of INSTALLED_APPS: INSTALLED_APPS += ( 'django_extensions', ) 2. Defined the model The model is really simple, and inherits from TimeStampedModel so we know when people signed up: from django.db import models from django_extensions.db.models import TimeStampedModel class NewsLetterSignup(TimeStampedModel): email = models.EmailField("Email") def __unicode__(self): return self.email 3. Wrote the view Here's the somewhat challenging part that forced me to dive into Django's source code. Even with the documentation work we've done over the past few months, it's clear we've got a long way to go. Because of that source code diving, for this blog post I really did my best to document why I did … -
Django GetOrCreateView
Today I decided to use the Django class based view (CBV) CreateView, but I wanted to avoid duplications and submit to the view from the front page of a site. The reason was for a simple newsletter signup form. This is what I cooked up and should work for Django 1.3, 1.4, and the forthcoming 1.5 release. Here is what I did: 1. Installed dependencies This version requires the following package to be pip installed into your virtualenv. django-extensions so we can have easy timestamps on models. This also needs to be added to your list of INSTALLED_APPS: INSTALLED_APPS += ( 'django_extensions', ) 2. Defined the model The model is really simple, and inherits from TimeStampedModel so we know when people signed up: from django.db import models from django_extensions.db.models import TimeStampedModel class NewsLetterSignup(TimeStampedModel): email = models.EmailField("Email") def __unicode__(self): return self.email 3. Wrote the view Here's the somewhat challenging part that forced me to dive into Django's source code. Even with the documentation work we've done over the past few months, it's clear we've got a long way to go. Because of that source code diving, for this blog post I really did my best to document why I did things … -
Los Angeles Open Source Sprint on Nov 4th!
Yet again, myself, Audrey Roy, and a small but elite cadre of volunteers are feverishly at work putting together another Los Angeles open source event. Our last effort went smashingly well, and like any good engineer, we're ready to scale up - this time to 150 attendees! LA Open Source #5 is a day long coding event for Open Source developers of all languages and skill levels to come and code like fiends. They'll be joined by dozens of either really smart coders or nice people like me. Sponsors are providing food, drinks, venue, and more! RSVP at http://www.meetup.com/LA-Hackathons/events/85658952/ I'll be there to: Co-lead the event with the assistance of the awesome Los Angeles technical community! Code like a fiend. I plan to work on core Django. Maybe some ember.js stuff too. And now to open the floor to questions... When and where? Where: Cross Campus (crosscamp.us) 820 Broadway Santa Monica, CA When: November 4th, 2012 10 AM to 9 PM Is this like a Hackathon? Yup. See http://en.wikipedia.org/wiki/Hackathon#Sprints What if I don't have a project of my own to bring? Should I come? Heck yeah! There will be a number of projects around that you can join and contribute … -
Los Angeles Open Source Sprint on Nov 4th!
Yet again, myself, Audrey Roy, and a small but elite cadre of volunteers are feverishly at work putting together another Los Angeles open source event. Our last effort went smashingly well, and like any good engineer, we're ready to scale up - this time to 150 attendees! LA Open Source #5 is a day long coding event for Open Source developers of all languages and skill levels to come and code like fiends. They'll be joined by dozens of either really smart coders or nice people like me. Sponsors are providing food, drinks, venue, and more! RSVP at http://www.meetup.com/LA-Hackathons/events/85658952/ I'll be there to: Co-lead the event with the assistance of the awesome Los Angeles technical community! Code like a fiend. I plan to work on core Django. Maybe some ember.js stuff too. And now to open the floor to questions... When and where? Where: Cross Campus (crosscamp.us) 820 Broadway Santa Monica, CA When: November 4th, 2012 10 AM to 9 PM Is this like a Hackathon? Yup. See http://en.wikipedia.org/wiki/Hackathon#Sprints What if I don't have a project of my own to bring? Should I come? Heck yeah! There will be a number of projects around that you can join and contribute … -
Django Contact Form with reCAPTCHA
How to add a reCAPTCHA field to the the Quixotix contact form. -
Multiple Databases in Django
Most of the challenges in the modern world of web development radicate in the one and only world that sounds like a trending topic: scalability. Most of us won't have huge scalability issue, let's be honest, we don't write a facebook or instagram every now and then, but we do have some large in-house applications that are used by a lot of users and need to handle huge amounts of data and one data base server isn't just enough, for that case Django give us support for multiple databases, but we need to configure a couple of things.Databases definitionsThe very first thing is tu define our databases in the settings.py file, only thing to have in mind is that we always need one named default, the names of the rest are up to you.DATABASES = { 'default': { 'NAME': 'db_name', 'ENGINE': 'django.db.backends.mysql', 'USER': 'mysql_user', 'PASSWORD': 's3krit' }, 'slave_name1': { 'NAME': 'db_name', 'ENGINE': 'django.db.backends.mysql', 'USER': 'mysql_user', 'PASSWORD': 'priv4te' }, 'slave_name2': { 'NAME': 'db_name', 'ENGINE': 'django.db.backends.mysql', … -
w00t: Nodejsconf Hackathon with great prizes! Last tickets: hurry up!
w00t: Nodejsconf Hackathon with great prizes! Last tickets: hurry up! There are still 30 nodejsconf and 4 nodejs beginner workshop tickets: hurry up! Hackathon Hackathon Hackathon!!! :) After the conference we’ll be waiting for you all at Talent Garden, a co-working space pretty close to the conference’s venue, for a little party with free beer and snacks, kindly offered by the jsDay’s guys, networking and chit-chats from 7pm to 9 pm. Once we’ll be all nice and happy (thx beer ;D) we’re gonna throw a “social” hackaton from 9 pm till the next day, November 11th, at 7 pm. Wait a sec, put down your smartphone and twitter, we’re not talking about social networks but socially helpfull stuff! Webforall, a non-profit organization founded by a group of passionate web developers that aims to bring professional web communication to other non-profits, will help with ideas and clues for those needing a little kick-start in the socially helpful field :) Ok this is not mandatory, but well, that’s the hackaton’s spirit so, if you’re able to put together a great piece of software in less than 24h and make it REALLY useful for the human kind that’s a total win! :) Don’t worry though, … -
w00t: Nodejsconf Hackathon with great prizes! Last tickets: hurry up!
w00t: Nodejsconf Hackathon with great prizes! Last tickets: hurry up! body,.backgroundTable{ background-color:#eeeeee; } #contentTable{ border:0px none #000000; margin-top:10px; } .headerTop{ background-color:#26292e; border-top:0px none #000000; border-bottom:0px none #FFCC66; text-align:center; padding:0px; } .adminText{ font-size:10px; color:#333333; line-height:200%; font-family:Helvetica; text-decoration:none; } .headerBar{ background-color:#26292e; border-top:0px none #333333; border-bottom:0px none #FFFFFF; padding:0px; } .headerBarText{ color:#333333; font-size:30px; font-family:Helvetica; font-weight:normal; text-align:left; } .postcardBarText{ color:#333333; font-size:30px; font-family:Helvetica; font-weight:normal; text-align:center; } .title{ font-size:24px; font-weight:bold; color:#4A8797; font-family:Helvetica; line-height:150%; } .subTitle{ font-size:14px; font-weight:bold; color:#000000; font-style:normal; font-family:Helvetica; } .defaultText{ font-size:12px; color:#333333; line-height:150%; font-family:Helvetica; background-color:#FFFFFF; padding:20px; border:0px none #FFFFFF; } .footerRow{ background-color:#26292e; border-top:0px none #FFFFFF; padding:20px; } .footerText{ font-size:10px; color:#666666; line-height:100%; font-family:Helvetica; } a,a:link,a:visited{ color:#17488a; text-decoration:underline; font-weight:normal; } .headerTop a{ color:#26292e; text-decoration:none; font-weight:normal; } .footerRow a{ color:#465F5D; text-decoration:underline; font-weight:normal; } body,.backgroundTable{ background-color:#26292e; } There are still 30 nodejsconf and 4 nodejs beginner workshop tickets: hurry up! Hackathon Hackathon Hackathon!!! :) After the conference we’ll be waiting for you all at Talent Garden, a co-working space pretty close to the conference’s venue, for a little party with free beer and snacks, kindly offered by the jsDay’s guys, networking and chit-chats from 7pm to 9 pm. Once we’ll be all nice and happy (thx beer ;D) we’re gonna throw a “social” hackaton from 9 pm till the next … -
DjangoCon 2012 Videos
DjangoCon 2012 Videos -
Open Source Contributions Come In All Shapes And Sizes
Open Source Contributions Come In All Shapes And Sizes -
How to Set Hijax with Django and jQuery
The main principle of progressive enhancement is that the markup, styling, and Javascript are separated. The site should be functional and browsable without Javascript, but when Javascript is activated, it can add additional functionality to the elements of a page. For example, it can hijack the default behavior of normal links replacing it with Ajax loading of just a specific part of the page. This type of progressive enhancement was called Hijax by Jeremy Keit. Hijax has the following benefits: Visitors can browse the content on any browser and on any platform. The content is indexable by search engines for each page. Open graph lets you share each page on Facebook with specific title, description and image. Let me show you an example of Hijax. Recently during my spare time I developed a simple collective storytelling game 1000 Words. Every participant at any point of a story has a chance to choose the continuation previously entered by someone else or to continue by his own words. It's like threaded comments where you see only one thread at a time. All continuations are browsable without Javascript and each of them has Open Graph set, so Google can index all variations of … -
django-statsd 0.3.8 - nose plugin
We use Statsd in combination with Django through django-statsd. The timing and profiling information it provides is really useful on a live site. The information can also be useful for debugging and developing locally, for example by exposing in django-debug-toolbar. How about unit tests? Well here's a nose plugin to expose that information. Combined with the patches inside django-statsd you can quickly get some useful information. Run your tests with the following plugin: --with-statsd You should (hopefully) get some nice information. This is the output when running with all the patches in solitude. ====================================================================== Statsd Keys | Number | Avg (ms) | Total (ms) ---------------------------------------------------------------------- cache.memcached.clear | 222 | 0.202703 | 45.000 cache.memcached.delete | 1 | 1.000000 | 1.000 cache.memcached.get | 7 | 0.428571 | 3.000 cache.memcached.set | 7 | 0.000000 | 0.000 db.mysql.default.execute | 572 | 0.575175 | 329.000 solitude.paypal.check-purchase | 3 | 0.666667 | 2.000 solitude.paypal.get-pay-key | 9 | 0.444444 | 4.000 solitude.paypal.get-refund | 5 | 0.000000 | 0.000 solitude.paypal.get-verified | 3 | 0.666667 | 2.000 solitude.paypal.ipn.validate | 11 | 0.000000 | 0.000 solitude.proxy.paypal.get-pay-key | 6 | 0.333333 | 2.000 ====================================================================== Statsd Counts | Number | Total ---------------------------------------------------------------------- solitude.paypal.post | 23 | 23 ---------------------------------------------------------------------- Ran 228 tests in … -
Django Transactional 0.5
A couple of days ago i released Django Transactional, a module for django that will make thing lot easier for common django ModelForm transactions. Today i extended it a bit and released 0.5, including these new functionality:Now it includes a base template so you don't need to create one, it will try to get your custom template and if it's not found it will use default one that just renders your form as_p in a form tag with id ModelForm.New mandatory key configuration 'include' which will be the dict used to format urls:'include': { 'app_or_nick1': ['model_or_nick1', 'model_or_nick2'], 'app_or_nick2': ['model_or_nick3', 'model_or_nick4'],} Improved url generation using 'include' key to get less 404 probabilities.If you want to contribute or just look at the code you can go to the bitbucket branch. And as usual, patches and feedback are welcome!