Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Browser ID
Browser ID is Mozillas new federated authentication system. This screencast walks you through using the django-browserid package to do your authentication, and attach it to the built in Django auth systemWatch Now... -
Selected for PyCon StartUp Row
Me and Audrey have been working hard on Consumer Notebook, a Python/Django based project. We submitted it to PyCon StartUp row and found out this morning we've been accepted. Hooray! From the PyCon StartUp Row winner's post, here is a little bit of what we're about: Have you tried researching products online recently? Search engines are gamed by scammy marketers. Product review sites overwhelm you with ads, have unreliable reviews, or dryly compare raw product specs. Consumer Notebook is working to solve this problem. It is like Yelp for products, with product comparison grids inspired by the founders' open-source work on Django Packages and Open Comparison. Just so you know, PyCon in North America is the biggest gathering for the international Python community. The conference this year is in Santa Clara, California, and is sold-out at 1500+ attendees, but could have easily sold out several times that number. The talks, tutorials, and events are going to be incredible, and I'm delighted to be part of the PyCon experience! We look forward to sharing the StartUp Row with friends like Transifex, Python Packages, and Wedding Lovely. Please check out Consumer Notebook right now and also visit our PyCon booth on Saturday, … -
Selected for PyCon StartUp Row
Me and Audrey have been working hard on Consumer Notebook, a Python/Django based project. We submitted it to PyCon StartUp row and found out this morning we've been accepted. Hooray! From the PyCon StartUp Row winner's post, here is a little bit of what we're about: Have you tried researching products online recently? Search engines are gamed by scammy marketers. Product review sites overwhelm you with ads, have unreliable reviews, or dryly compare raw product specs. Consumer Notebook is working to solve this problem. It is like Yelp for products, with product comparison grids inspired by the founders' open-source work on Django Packages and Open Comparison. Just so you know, PyCon in North America is the biggest gathering for the international Python community. The conference this year is in Santa Clara, California, and is sold-out at 1500+ attendees, but could have easily sold out several times that number. The talks, tutorials, and events are going to be incredible, and I'm delighted to be part of the PyCon experience! We look forward to sharing the StartUp Row with friends like Transifex, Python Packages, and Wedding Lovely. Please check out Consumer Notebook right now and also visit our PyCon booth on Saturday, … -
Django class based views (III)
En aquest apunt veurem com fer servir les generic class views per a fer feina amb formularis. Seguirem la documentació de Django que tracta dels formularis. Allà ens fa referència a un formulari de contacte creat com: from django import forms class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() sender = forms.EmailField() cc_myself = forms.BooleanField(required=False) i la vista associada def contact(request): if request.method == 'POST': # If the form has been submitted... form = ContactForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... return HttpResponseRedirect('/thanks/') # Redirect after POST else: form = ContactForm() # An unbound form return render_to_response('contact.html', { 'form': form, }) El que farem ara és fer el mateix però fent servir les generic class views. El primer que hem de veure és què hem de fer servir. Necessitam gestionar un formulari, la seva validació i tornar la redirecció cap a una nova plana web en cas que tot vagi bé. Si feim una ullada a la jerarquia de classes del mòdul edit podem veure que la classes que compleix tot el que volem es diu FormView. FormView està composada pel mixin TemplateResponseMixin … -
Django class based views (II)
En aquesta segona part veurem alguns dels usos més interessants de les class based views per a presentar informació i estalviar-nos feina. TemplateView Com ja vàrem veure a la primera part el TemplateView ens estalvia molta feina respecte a la manera tradicional de fer les coses, sols pel fet de passar ja el RequestContext ja recomanaria passar-nos al nou món de les Class Based Views, però encara hi ha més! TemplateView incorpora dos mètodes més get_context_data i get. Amb el get el que fa es cridar al mètode render_to_response que ens proporciona el mixin TemplateResponseMixin i passant-li com a arguments el diccionari que ens ha de tornar el mètode get_context_data. Per defecte get_context_data ens retorna un diccionari amb els paràmetres que venen de la url, així si la nostra url és url(r'^test3/(?P<id>\d+)/$', Test3View.as_view(), name="test3-class-view"), llavors get_context_data conté el diccionari {'id': 3} i a la plantilla es passarà una variable anomenada params amb aquest diccionari. Suposem però que no és això exactament el que volem. Volem que passi a la plantilla una variable anomenanda id amb una salutació per als lectors del blog. El que farem serà sobreescriure get_context_data per a que passi la informació que nosaltres volem a la plantilla. … -
My blog is moved
From now on I'll be blogging from http://pydanny.com.See you there! -
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 !== …