Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Function Based Views Are My First Love
There is something special about your first love. It is possible be too attached and not embrace the new hotness of say Class Based View (CBV). But after having a fling and then dating CBV for a while, I now know that Function Based Views will always have a special place in my heart, and I hope in Django. Let's look at a FBV: def foo(request, arg, template="foo.html"): # Do something return render(request, template, dict(bar="bar")) Simple. Beautiful. Easy to follow. An explicit context filled with exactly what is available in the template and what names those values have. No extra docs needed. Explicit request and response, and the path to get from one to the other is outlined in one place, in one file. This straight forward approach of FBVs also makes it easier to learn and debug. Most University Computer Science programs are moving away from teaching Object Oriented Programming first and instead focusing on functional and procedural programming because it is easier to learn. There is a time and a place to use the power of classes and in Django CBVs. Consider carefully if your problem is really the kind where you need to use the CBV shaped … -
Function Based Views Are My First Love
There is something special about your first love. It is possible be too attached and not embrace the new hotness of say Class Based View (CBV). But after having a fling and then dating CBV for a while, I now know that Function Based Views will always have a special place in my heart, and I hope in Django. Let's look at a FBV: def foo(request, arg, template="foo.html"): # Do something return render(request, template, dict(bar="bar")) Simple. Beautiful. Easy to follow. An explicit context filled with exactly what is available in the template and what names those values have. No extra docs needed. Explicit request and response, and the path to get from one to the other is outlined in one place, in one file. This straight forward approach of FBVs also makes it easier to learn and debug. Most University Computer Science programs are moving away from teaching Object Oriented Programming first and instead focusing on functional and procedural programming because it is easier to learn. There is a time and a place to use the power of classes and in Django CBVs. Consider carefully if your problem is really the kind where you need to use the CBV shaped … -
Combining Twisted and Django
Franco Nero as the twisted gunslinger DjangoNewcomers to Evennia sometimes misunderstand it as being a "Django mud codebase somehow using Twisted". The correct description is rather that Evennia is a "Twisted-based mud server using Django". Allow me to elaborate.A mud/mux/moo/mu* is per definition a multi-user online game system. All these users need to co-exist on the server. If one player does something, other players shouldn't have to (noticeably) wait for that something to end before they can do anything. Furthermore it's important for the database schema to be easy to handle and upgrade. Finally, in a modern game, internet presence and web browser access is becoming a must. We combine two frameworks to achieve this.Two frameworks combinedTwisted is a asynchronous Python framework. "Asynchronous" in this context means, very simplified, that Twisted chops up code execution into as small bits as the code lets it. It then flips through these snippets rapidly, executing each in turn. The result is the illusion of everything happening at the same time. The asynchronous operation is the basis for the framework, but it also helps that twisted makes it easy to support (and create) a massive range of different network protocols.Django implements a very nice abstract Python … -
Moving Sentry from Heroku to Hardware
Update: Don’t decide against Heroku just because you’ve read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I’ve talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and … -
Moving Sentry from Heroku to Hardware
Update: Don't decide against Heroku just because you've read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I've talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and how I switched ... -
Pensar en el manteniment compensa
Avui, fa poques hores hem posat en producció una nova web per Fiesta Hotel Group anomenada Palladium Weddings és una web pensada per pantalles grans, on s'intenta mostrar el que és el producte de noces que té el client. Si us pensau casar aviat o renovar vots, no deixeu de fer-li una ullada, els escenaris i ambients són una autèntica meravella. Com és habitual la web està desenvolupada amb Django i pensada per a suportar una càrrega important de visites, i a la vegada fer que el manteniment dels continguts sia el més ràpid possible. Pensau que muntar un paquet de noces, amb tot els extres, fotografies, escenaris, ... no és una tasca trivial. Ens hem de posar amb la pell no tan sols del client potencial que visita la web, sinó de la gent que l'ha de mantenir, i per tant l'aplicació s'ha de cuidar tant en l'aspecte visible com en el que es veu menys, però que també té una part fonamental en l'èxit de la web. Si aconseguim fer una web fàcil de mantenir és més senzill que els continguts es mantenguin actualitzats i que la web estigui més viva. Però a part d'aquestes consideracions, per mi … -
Django scaffolding
We all love Django — a simple but powerful framework. However, Ruby on Rails has at least one (and few others I’m sure!) advantage: scaffolding. It allows developers to create the models, views, and templates in a single operation. It’s an interesting solution — you don’t have to manually create all the things that usually take a lot of time. So why don’t we have this feature in Django? Well… now we do! Our latest django-common 0.3 comes with a scaffolding feature! Overview Here is what django-common scaffold can do: - create app, - create models, - create views, - create templates, - create forms, - create urls, - create tests. Scaffold creates the app (similar to startapp that ships with Django), models with fields, CRUD views with ajax forms, prepares templates, fills urls, and creates CRUD tests with only one command! Installing Use pip installer: pip install django-common-helpers Or just download/clone directly from github: https://github.com/Tivix/django-common Then add it (django_common) to INSTALLED_APPS and set up SCAFFOLD_APPS_DIR in settings. Default is set to main app directory. However if you use django_base_project you must set up this to SCAFFOLD_APPS_DIR = ‘apps/’. Run scaffold, run! To run scaffold type:python manage.py scaffold APPNAME --model … -
Moving Sentry from Heroku to Hardware
Update: Don't decide against Heroku just because you've read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I've talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and how I switched ... -
Integrating reCAPTCHA
Recently we've been looking into using reCAPTCHA for a form on the 2degrees site. We took a look at the python libraries out there and found that they either didn't meet our requirements or weren't sufficiently documented to allow a quick integration with our software.So, we've developed a couple of open-source libraries to allow easy communication with the reCAPTCHA service:python-recptcha is an alternative to the client that google suggest. We've created a fully-tested and well-documented alternative which allows access to the whole API. The main advantage here, is the ability to access the different themes on offer.django-recaptcha-field is a small library which contains a factory for generating a Django form with a reCAPTCHA field in. All the other libraries we found worked around passing the client IP address to the reCAPTCHA service. Given that the API documentation states that this is a mandatory field, we've ensured that this is sent.If you have any suggestions for future improvement in these libraries, we'd love to hear from you. Of course, if you'd like to make the changes yourself you can always fork the libraries on github! -
Integrating reCAPTCHA
Recently we've been looking into using reCAPTCHA for a form on the 2degrees site. We took a look at the python libraries out there and found that they either didn't meet our requirements or weren't sufficiently documented to allow a quick integration with our software. So, we've developed a couple of open-source libraries to allow easy communication with the reCAPTCHA service: python-recaptcha is an alternative to the client that google suggest. We've created a fully-tested and well-documented alternative which allows access to the whole API. The main advantage here, is the ability to access the different themes on offer. django-recaptcha-field is a small library which contains a factory for generating a Django form with a reCAPTCHA field in. All the other libraries we found worked around passing the client IP address to the reCAPTCHA service. Given that the API documentation states that this is a mandatory field, we've ensured that this is sent. If you have any suggestions for future improvement in these libraries, we'd love to hear from you. Of course, if you'd like to make the changes yourself you can always fork the libraries on github! -
Accessibility: Look at What's Out!
Overnight, my book on making accessible websites was released. It's my first book, and I'm completely over the moon. Not only do I get my own animal, but I get to put a book out on something I'm passionate about. I get to help break the paradigm that accessibility is too expensive, just about the blind, or only benefits a small portion of the population. Even better is the timing: I'm teaching a tutorial at DjangoCon on making accessible websites. I've been super jazzed about being able to do more than drive-by conversations with people about accessibility. It's one of those topics that many people approach with skeptisism, but leave with a budding interest. This time, I'll be able to take that interest and mold it into a deeper understanding in what it means to be accessible. We also get to improve a really bad restaurant site, which I think will be cathartic for most of us. There's space at the tutorial, so if you're at DjangoCon or in the DC area, you can still sign up! And heck, you can say you took a class on accessibility from the woman who wrote a book on it. -
Pushing a git branch
We're using git for most django projects now. There's one big problem I had: if I make a branch and want to push my changes to github, I sometimes get an error complaining that I'm behind on other branches so that my changes can't be pushed. The "solution" is to do a git checkout master, pull there (which updates my master pointer), and checkout back to my branch. Now I can push. This is pretty irritating. Why can't I just push the branch I'm working on? I found the solution on stackoverflow: git config --global push.default current This pushes only the current branch by default. Just what I wanted. -
Getting Started with Pinax Starter Projects
When I first started contributing to Pinax, one of the most exciting things to me was this idea of starter projects where you could be up and running with a certain type of a site literally within minutes. It was even more exciting to be able to shed having to build and maintain a lot of the infrastructure code around supporting project templates when Django started supporting the --template flag on django-admin.py startproject. We moved to having separate repositories for each of our starter projects and even these have the templates shipped separately with the notion of pluggable themes that are simply an app that you add to your requirements and INSTALLED_APPS. This is something James Tauber and I worked out rough versions of way back when we started KodeNode but with the breaking apart of Pinax this concept has really proven itself. Luke Hatcher has taken this idea to entirely new heights in building and maintaining an awesome theme, called pinax-theme-bootstrap based on Twitter Bootstrap. The old pinax.apps.account app has been completely rewritten by Brian Rosner and is more extensible than ever with some really incredible features as a stand alone Django reusable app called django-user-accounts. The starter project that I use for just about everything, combines django-user-accounts and pinax-theme-bootstrap to yield the pinax-project-account starter … -
A BASE_URL Template Variable in Django
A simple way to provide a BASE_URL variable to Django templates -
Twitter Bootstrap and AJAX
As a long time web developer who has struggled with being comfortable with doing front-end development, having Twitter Bootstrap available is nothing short of transformative. The aspect that I am most enamored with is how much the bar has been lowered for guys like me to make relatively large UI changes without the need to segment work out to UI experts. However, I was writing the same bits of Javascript everywhere to do simply little things with $.ajax in jQuery. Code was fragile and often I would defer making the experience of doing some less polished/snappy because it would mean having to write some more of the same old Javascript that I was bored writing. "Ah, a POST followed by the 302 redirect isn't too bad, let's just roll with that for now...", I would say to myself. So, I created bootstrap-ajax.js. For the record, I don't think that all traditional form submissions followed by the standard 302 redirect are bad. In many cases it's exactly all that is needed and works well. You have to make the call for yourself and in the context of your own web apps what works best for each situation. What if we could break down the problem and … -
Caktus is hiring a Web Project Manager
Caktus is currently hiring for a full time Web Project Manager to be a part of our awesome team. We’re a diverse team of smart, sharp developers and designers with a passion for creating customizable, content rich sites and web applications using Django. As one the project managers at Caktus, you’ll have the opportunity to develop your professional skills and also get the chance to work with some very capable and nice people. We are looking for someone who is meticulous when it comes to detail, is able to see the overarching goals of projects and has a special place in their heart for spreadsheets. Also it would not hurt if you had knowledge about Django and agile web development. Your job will consist of assisting with product deployments, managing client communications and assisting with creating estimates for incoming projects. If you think you might be a great fit or know someone who might be, check out the full job posting here. -
Performance metrics for a social network
This is a talk I gave at the Amsterdam Performance Meetup. The presentation starts by introducing Fashiolista. It still amazes me and 3 other guys started Fashiolista and grew it to the 2nd largest online Fashion community. I guess Marc Andreesen had a point in his “Why Software Is Eating The World” article. The talk focuses on how we use metrics to drive optimization at Fashiolista. And narrows down on tools like: NewRelic Graphite PgFouine If you’re looking up the links from the presentation, these are the most notable ones: Etsy on Statsd Instagram on PgFouine Fashiolista Jobs My Github Django Facebook The Presentation Performance metrics for a social network from Thierry Schellenbach Share and Enjoy: -
django CMS 2.3.1 released
-
CMS Placeholders and YOU!
Here at Imaginary, a number of our client sites make use of the excellent Django-CMS which provides CMS pages that can be populated with a variety of content plugins. This allows client faculty to manage content on CMS-specific pages without the continued involvement by our production staff. This is pretty ... -
A Public Service Message to the Python Community
Hi, I'm Daniel Greenfeld. You might know me from my blog. I'm here to talk to you about a very import subject: Submitting your talk early to PyCon US. Last year there were hundreds of talks were submitted for just a very few speaking slots. Unpaid volunteers labored for hours before and after their normal jobs reviewing and debating which talks were to get in. The volume of talks combined with simple reviewer fatigue means that earlier submitted talks got more attention. This year, following the pattern of previous years, we're going to have 25% more talk submissions. Please don't leave your poor talk or tutorial out in the cold. Submit early. Help us fix the problem in one of two ways: Submit your talk as early as possible. Help review PyCon US talks. Production notes for this service message I've always wanted to do one of those TV public service messages done by B or C grade actors. As a D-grade blogger I thought I might be a pretty good match for the role. :-) -
A Public Service Message to the Python Community
Hi, I'm Daniel Greenfeld. You might know me from my blog. I'm here to talk to you about a very import subject: Submitting your talk early to PyCon US. Last year there were hundreds of talks were submitted for just a very few speaking slots. Unpaid volunteers labored for hours before and after their normal jobs reviewing and debating which talks were to get in. The volume of talks combined with simple reviewer fatigue means that earlier submitted talks got more attention. This year, following the pattern of previous years, we're going to have 25% more talk submissions. Please don't leave your poor talk or tutorial out in the cold. Submit early. Help us fix the problem in one of two ways: Submit your talk as early as possible. Help review PyCon US talks. Production notes for this service message I've always wanted to do one of those TV public service messages done by B or C grade actors. As a D-grade blogger I thought I might be a pretty good match for the role. :-) -
A Public Service Message to the Python Community
Hi, I'm Daniel Greenfeld. You might know me from my blog. I'm here to talk to you about a very import subject: Submitting your talk early to PyCon US. Last year there were hundreds of talks were submitted for just a very few speaking slots. Unpaid volunteers labored for hours before and after their normal jobs reviewing and debating which talks were to get in. The volume of talks combined with simple reviewer fatigue means that earlier submitted talks got more attention. This year, following the pattern of previous years, we're going to have 25% more talk submissions. Please don't leave your poor talk or tutorial out in the cold. Submit early. Help us fix the problem in one of two ways: Submit your talk as early as possible. Help review PyCon US talks. Production notes for this service message I've always wanted to do one of those TV public service messages done by B or C grade actors. As a D-grade blogger I thought I might be a pretty good match for the role. :-) -
DjangoCon and PyCon Canada
This fall I am venturing into the conference circuit starting with DjangoCon US in Washington DC, in September. I am definitely looking forward to seeing what it like to attend a major open source conference. I would also like to try to meet up with other Canadians making there way down to DjangoCon this year. Comment here or on find me on Twitter. Then in November in Toronto an excellent group of Python developers are launching PyCon Canada to help build community for 2014 when the official North American PyCon comes to Montreal. From the 9th the 11th of November in Toronto there will be a full fledged regional PyCon conference with talks, tutorials and sprints. Registration is open and they are accepting speaker applications. The next obvious step will be to plan a conference of my own. -
Sphinx Doc, JSON highlight and Sphinx extensions: kung-fu
At the moment Pygments which used by Sphinx Doc haven't support for JSON code highlight which is really sad.I've not found any useful information how to do it quickly. So here is my way:I've found custom pygments lexer which support JSON: pygments-json . I will be part of pygments soonIt wasn't clear to me how to add custom pygments lexer to sphinx, my google-fu isn't good todayA bit more googling gave me Sphinx Extensions API , especially add_lexer method of Sphinx instance Ok, now it's clear to me how to add new lexer. I've created ext/hijson folder within source, to __init__.py I've added setup function: Also here is how to add support of ext folder as folder with custom extensions So, pip install pygments-json and use .. code-block:: json Nice and smooth: -
How to Easily Add Referrals to a Website
Referrals are a popular and very effective way to generate quality traffic while allowing users that love your site to become promoters. We built anafero because we were increasingly wanting to deploy referral systems on more of our sites as well as sites for some of our clients. Multiple Uses There are multiple ways that anafero can be used. We have used anafero specifically in these various contexts: Generate one referral per user and just display a simple number to them to show how many responses they have generated. Setup of specific activities that you want to track and report to the referring user (e.g. not just that respondents clicked on the link but that they signed up as well). Allow users to generate their own referrals, naming them, so that they can track different channels and what methods of promoting the site are working for them. Let users use generated referral links to act as semi-private share links that unlocks private content for the visitor but only when they get to the site using the private referral link. Setup thresholds that when a referring user surpasses certain goals they receive an award. This is what we are doing on Gondor (you can see …