Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django class based views (I)
Class based views Amb Django 1.3 s'introdueixen les "Class based views", una funcionalitat que ens permet modelar les nostres vistes com a classes i que a més intenta solucionar el no tenir que escriure sempre el mateix tipus de codi quan mostram una plana web o fem un manteniment lligat a un model de dades. Les class based views ens permeten un nivell més alt de reutilització del nostre codi i a més ens permeten de mantenir-ne la cohesió. Fins ara o bé teníem que anar creant les funcions dins la mateixa vista, dins la mateixa funció o tirar de mòduls independents. Amb les class based views pode anar creant funcions per a la nostra vista, de manera que després sigui més bo de fer reaprofitar-les extenent la classe. En poques paraules, les class based views requereixen un temps d'adaptació i alguns diuen que aprendre un nou DSL (Domain Specific Language). Potser sí, però s'ho paga. Abans de començar Encara que podem utilitzar les nostres pròpies class based views, Django ens dóna ja fetes les més freqüents i un conjunt de classes que podem fer servir en cas que cap ens encaixi. És en aquestes classes on hi ha gran … -
Replacing Redis with a Python Mock
tl;dr When writing tests, mock out a subsystem if and only if it’s prohibitive to test against the real thing. !tl;dr Our product uses Redis. It’s an awesome technology. We’ve avoided needing Redis in our unit tests. But when I added a product feature that made deep use of Redis, I wrote its unit tests to use it, and changed our development fabfile to instantiate a test Redis server when running the unit tests locally. (A QA purest might argue that unit tests should never touch major system components outside of the unit under test. I prefer to do as much testing as possible in unit tests, provided they don’t take too long to run, and setup and teardown aren’t too much of a PITA.) This was a contributory reason for our builds now failing on our Hudson CI server. Redis wasn’t installed on it! Why didn’t I immediately install Redis on our CI server? Our CI server had other problems I intended to nuke it and re-create it with the latest version of Jenkins. I just needed to first clear some things off my plate Our dev team had shrunk down to just two people We were both strict … -
Font size feedback wanted
-
django-uni-form end of life
I started on django-uni-form in January 2009. In order to use Pinax on an internal social network for NASA HQ, we had to render all content, including forms, Section 508 compliant. Rather than rewrite the html for all 50+ forms that existed in the Pinax 0.5.x framework at that time, I decided to minimize my work and automate things. James Tauber gave guidance and insight, my co-workers were supportive, and Jannis Leidel suggested the Uni-form library. The name Django Uni-Form was obvious, and lo the project was named. Looking at the old, extremely deprecated Google Code site for django-uni-form, I see that the first commit happened on January 7th, 2009. That was for version 0.1, with some core code that was literally a merger between the Django form example on how to integrate divs into forms and the simplest template tag I could figure out. The python code in uni_form/templatetags/uni_form.py: from django.template import Context, Template from django.template.loader import get_template from django import template register = template.Library() @register.filter def as_uni_form(form): template = get_template('templates/uni_form.html') c = Context({'form':form}) return template.render(c) The template tag code was nearly exactly copy/pasted from the starter Django docs on forms: {% for field in form %} <div class="ctrlHolder … -
django-uni-form end of life
I started on django-uni-form in January 2009. In order to use Pinax on an internal social network for NASA HQ, we had to render all content, including forms, Section 508 compliant. Rather than rewrite the html for all 50+ forms that existed in the Pinax 0.5.x framework at that time, I decided to minimize my work and automate things. James Tauber gave guidance and insight, my co-workers were supportive, and Jannis Leidel suggested the Uni-form library. The name Django Uni-Form was obvious, and lo the project was named. Looking at the old, extremely deprecated Google Code site for django-uni-form, I see that the first commit happened on January 7th, 2009. That was for version 0.1, with some core code that was literally a merger between the Django form example on how to integrate divs into forms and the simplest template tag I could figure out. The python code in uni_form/templatetags/uni_form.py: from django.template import Context, Template from django.template.loader import get_template from django import template register = template.Library() @register.filter def as_uni_form(form): template = get_template('templates/uni_form.html') c = Context({'form':form}) return template.render(c) The template tag code was nearly exactly copy/pasted from the starter Django docs on forms: {% for field in form %} <div class="ctrlHolder … -
Satchmo Diaries
Bob Waycott from Medium Labs has written some great articles on customizing Satchmo. -
Using Django Permissions
I recently had the need to use the Django permission system and couple it with newforms admin. There were a couple of tricks in the process so hopefully this will be useful for you. -
Satchmo 0.8 Release
After 6 months of development activity, Satchmo 0.8 is now released and represents the first official Satchmo release that is compatible with Django 1.0. -
Satchmo DjangoCon Video Available
The satchmo YouTube video and presentation from Djangocon are now available. -
Thoughts from DjangoCon 2008
I'm back from Djangocon and wanted to write up a few notes regarding the trip. Like most people have already commented, Djangocon was a great conference. The talks were almost universally well done - interesting, engaging and I had some good learning from almost every one... -
Django 1.4 beta 1 lançado
Django 1.4 beta 1 lançado -
Django 1.4 beta 1 lançado
Django 1.4 beta 1 lançado -
Silicon Beach Hackercast
Near the end of January of 2012 I was at the 10th Southern California Linux Exposition (SCALE 10X). I gave an Intro to Python talk, helped man the awesome Python booth, and hung out with a lot of awesome people. One of those awesome people I got to spend time with was Andrew Cholakian, a Ruby and Clojure developer, and the organizer of LA Hacker News. We've been meaning to do something together, and at the conference we decided to do a broadcast together.Jump forward a few weeks and Andrew came over to our place in the San Fernando Valley for a day of brainstorming, web site building, and broadcasting. We outlined a show and started to record.Download Now!Topics of DiscussionPython at Scale 10XNew clients asking you to complete the ‘last 10%’A rant about job titlesWhy is clojure blowing up?LinksSilicon Beach HackercastSilicon Beach Hackercast Episode #1Hacker News ThreadArtAudrey was kind enough to illustrate the event for posterity: The FutureThe show was a lot of fun to do. We plan to do more of them, perhaps every few weeks. A better microphone is definitely in the works. -
Such a small thing ...
Lately I went back to clean up and optimize the workings of Evennia's Attributes. I had a nice idea for making the code easier to read and also faster by caching more aggressively. The end result was of course that I managed to break things. In the end it took me two weeks to get my new scheme to a state where it did what it already did before (although faster).Doing so, some of the trickier aspects of implementing easily accessible Attributes came back into view, and I thought I'd cover them here. Python intricacies and black magic to follow. You have been warned. Attributes are, in Evennia lingo, arbitrary things a user may want to permanently store on an object, script or player. It could be numbers or strings like health, mana or short descriptions, but also more advanced stuff like lists, dictionaries or custom Python objects. Now, Evennia allows this syntax for defining an attribute on e.g. the object myobj:myobj.db.test = [1,2,3,4]This very Pythonic-looking thing allows a user to transparently save that list (or whatever) to an attribute named, in this example, test. This will save to the database. What happens is that db, which is a special object … -
Forms Part 5: Basic Form Validation
Forms are a big subject in Django. We have run through a lot when it comes to forms. We are concluding our series with Form Validation. This simple video will finalize everything we have done so far by allowing us to give feedback to our users when our form validation goes wrong.Watch Now... -
Forms Part 5: Basic Form Validation
Forms are a big subject in Django. We have run through a lot when it comes to forms. We are concluding our series with Form Validation. This simple video will finalize everything we have done so far by allowing us to give feedback to our users when our form validation goes wrong.Watch Now... -
MyghtyBoard 2012 first beta available - a simple and handy Django forum application
After a long time I've found some time to release the current version of the forum app I'm using. It's named "MyghtBoard" and the test-version looks like so: You can download the code from the project site either from ZIP file or from SVN. This is a first release after a while so it may contains some bugs. The application consist of forum categories, which contain forums. Each forum has its own topic and topics have posts. Topics may also be global - shown in every forum, or sticky - always on top of the forum. Forums may also use tags - admin selected tags that users will be able to choose for their topics (or filter topics by tags). Topics may be moved to other forums, locked/unlocked, solved/unsolved and so on... -
Djaxaproject, segona part
Abans d'escriure aquest apunt de m'he adonat que era el post amb l'identificador 500. Un nombre rodó i que potser mereixeria algun tipus de celebració, però tanmateix no és l'apunt que fa 500, ja que en les proves del codi del blog, segurament vaig afegir i esborrar apunts que han fet anar cap endavant el comptador, realment encara falten prop d'una trentena d'apunts per a arribar al que fa 500, així que deixaré el cava a la gelera. Hi va haver una proposta de celebrar-ho fent un regal, però pareix que la meva proposta de regalar una capsa d'un Nexus (tot i que comptava amb un possible patrocionador) no ha arribat a cuallar :-P Així doncs el que faré és reprende l'apunt sobre el dajaxproject, i em centraré en l'altra component, anomenat Dajax. Dajax Ja vàrem veure com dajaxice ens deixava fer cridades AJAX cap a la nostra aplicació Django i organitzar-les. Dajax va més enllà in ens permet interactuar amb la interfície d'usuari des de codi Python. Fet servir amb mesura i seny ens pot ajudar també a fer molt més legible el nostre codi i a organtizar millor les accions derivades d'una cridada AJAX dins el mateix codi … -
Headless JavaScript testing, Sinon.js, Fake Timers and Rhino
Recently I've started to use TDD approach with development of client-side code/JavaScript. The code on front-end become more complex and it have to be tested along with back-end code.One of first things which I've found was Sinon.js - the mock library to make my life easier. Btw, I'm using Jasmine for writing tests. So, everything looks great until I've tried to integrate my tests into our CIA (Jenkins).The tests which working great within browser failed using rhino/env.js. That was weird and unfortunately tracebacks were useless. I've started to go deeper and found an article which make things clear to me: Sinon.js have issues with timers.Update: I've fixed issue with Sinon.JS Fake Timers and Rhino.jsI've made small stub to replace functionality of fake timeouts from Sinon.js and wow, tests are passed!// setTimeout/clearTimeout stub using Underscore.jsvar FakeTimeout = function () { var self = this, timers = [], counter = 1, timeoutOrig = setTimeout, clearOrig = clearTimeout; // add new timeout to the queue this.setTimeout = function (f, timeout) { var id = counter++; timers.push({ 'callback': f, 'timeout': timeout, 'id': id }); return id; }; // cleanup timeout this.clearTimeout = function (id) { timers = _.filter(timers, function (item) { return item.id !== … -
Fashiolista in NY
The Fashiolista team is in New York for the fashion week. I’m looking forward to meet some local tech startups. Drop me a mail or leave a comment if you want to grab a coffee. Cheers, Thierry Schellenbach CTO/ Founder Fashiolista Share and Enjoy: -
Django for beginners
Hello, This is my first blog post and I want to dedicate this to all those web developers out there , who want to move to django for backend developement. This post contains details of installing django and setting up the basic settings to get started with. For all those who are wondering what is django, please look up here. Prerequisites : 1) This post contains the details of installing django on a linux machine. For windows and mac users, the installation procedure might slightly vary. However the setting up of django settings, once the installation is done remains the same. 2) The post is written with the assumption that the user is familiar with basic python. For tutorials on python, please look up here. Installation Procedure: Now that we are done with the talking lets get our hands wet. To install django, download the tarball of the official release here . Please make sure you download the official release from the link in topic 1 of the page mentioned above. Once the tar is downloaded, extract it to a suitable folder of you choice. In my example , I am extracting it to /home/abinav. To extract the tarbal, run … -
The right way not to do things
The right way not to do things -
Release 0.6.6
We just released LFS 0.6.6. This is a yet another bugfix release. Changes Bugfix: fixed url for Pages at breadcrumbs (Maciej Wisniowski) Bugfix: display sale price at category products page (Maciej Wisniowski) Bugfix: fix product pagination (Maciej Wisniowski) Bugfix: added short_description to category management UI Bugfix: display category descriptions Bugfix: fixed template selection; issue #134 Improvement: allow easy modification of category/product templates (Maciej Wisniowski) Updated polish translations (Maciej Wisniowski) News: We have setup a GitHub mirror of LFS. The docs are running on our own domain now (still hosted on RTD) and have a new layout: http://docs.getlfs.com/ Information You can find more information and help on following locations: Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org and github. Google Group lfsproject on Twitter IRC -
How to Prevent Memory Bloat in Mongo
Feed Mongo!! Several months ago at Yipit, we decided to cross the NoSQL rubicon and port a large portion of our data storage from MySQL over to MongoDB. One of the main drivers behind our move to Mongo was the composition of our data (namely, our recommendation engine system) which consists of loosely structured, denormalized objects best represented as a JSON-style documents. Here’s an example of a typical recommendation object. How Key Expansion Cause Memory Bloat Because any given recommendation can have a number of arbitrary nested attributes, Mongo’s “schemaless” style is much preferred to the fixed schema approach imposed by a relational database. The downside here, though, is that this structure produces extreme data duplication. Whereas a MySQL column is stored only once for a given table, an equivalent JSON attribute is repeated for each document in a collection. Why Memory Management in Mongo is Crucial When your data set is sufficiently small, this redundancy is usually acceptable; however, once you begin to scale up, it becomes less palatable. At Yipit, an average key size of 100 Bytes per document, spread over roughly 65 million documents, adds somewhere between 7GB-10GB of data (factoring in indexes) without providing much value … -
Mock testing long polling