Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 … -
Travis CI Presentation
Here’s the presentation I gave about using Travis CI and Django. If you haven’t used TravisCI yet I strongly suggest doing so. If you don’t have any tests for your application to warrant such a program than why are you reading this? Go out and write tests! Related posts: Welcome to ProcrastinatingDev -
Taking command
Commands are the bread and butter of any game. Commands are the instructions coming in from the player telling the game (or their avatar in the game) to do stuff. This post will outline the reasoning leading up to Evennia's somewhat (I think) non-standard way of handling commands.In the case of MUDs and other text games commands usually come in the form of entered text. But clicking on a graphical button or using a joystick is also at some level issuing a command - one way or another the Player instructs the game in a way it understands. In this post I will stick to text commands though. So open door with red key is a potential command. Evennia, being a MUD design system, needs to offer a stable and extensive way to handle new and old commands. More than that, we need to allow developers pretty big freedom with developing their own command syntax if they so please (our default is not for everyone). A small hard-coded command set is not an option.Identifying the commandFirst step is identifying the command coming in. When looking at open door with red key it's probably open that is the unique command. The other … -
Django Requirements 2012-08-15
A little over three months ago I blogged about my preferred requirements list. It's now nearly the eve of Django Dash, and I feel it's time to update the list. I'm going to bump the versions on some of the existing packages and add some new ones to the list. New Packages django-braces==0.1.3 Want to use Django Class Based Views but unhappy with the missing components like LoginRequiredMixin, SelectRelatedMixin, and even StaffuserRequiredMixin? Not to worry, as this library will make Django CBVs 134% easier to use. django-secure==0.1.2 Django is rather secure, but there is a checklist of things that the security experts want you to do. Save yourself forgetting something and use this library to do all those little things. django-profiletools==0.1.3 Have you ever used the django-debug-toolbar and noticed that you did that same request.user.get_profile() call a dozen times? Ever want to just call that once? This library, by yours truly, resolves the issue. It loads the user's profile object once, and then passes it down the request chain. Existing Packages Django==1.4.1 If you need sessions, forms, templates, and relational database models, then I can argue you've got the ideal Django project. Make certain you are running the latest Django … -
Django Requirements 2012-08-15
A little over three months ago I blogged about my preferred requirements list. It's now nearly the eve of Django Dash, and I feel it's time to update the list. I'm going to bump the versions on some of the existing packages and add some new ones to the list. New Packages django-braces==0.1.3 Want to use Django Class Based Views but unhappy with the missing components like LoginRequiredMixin, SelectRelatedMixin, and even StaffuserRequiredMixin? Not to worry, as this library will make Django CBVs 134% easier to use. django-secure==0.1.2 Django is rather secure, but there is a checklist of things that the security experts want you to do. Save yourself forgetting something and use this library to do all those little things. django-profiletools==0.1.3 Have you ever used the django-debug-toolbar and noticed that you did that same request.user.get_profile() call a dozen times? Ever want to just call that once? This library, by yours truly, resolves the issue. It loads the user's profile object once, and then passes it down the request chain. Existing Packages Django==1.4.1 If you need sessions, forms, templates, and relational database models, then I can argue you've got the ideal Django project. Make certain you are running the latest Django … -
Dutch Python meeting on *friday* 21 september in Utrecht
The Dutch Python meeting ("PUN") in september will be on a FRIDAY evening instead of the customary wednesday evening because one of the speakers can't come on regular weekdays, so we're trying it out on this alternative day! I guess some people cannot come on a friday, but probably lots of others can come especially because it is a friday. Please add your name on the wiki page (or alternatively email me) if you think you'll come, that way I can have an idea of how many people will show up. (You can come anyway even if you don't add your name, it is just to help me plan the drinks). The location is conveniently in the center of Utrecht, close to the central station, at Nelen & Schuurmans (same location as January last year, for those that were there). So you can get there easily. If you come by car, there's a car park very close at hand just behind the "Bijenkorf". So... Look at the agenda for the two main talks and start adding a lighting talk of your own! (p.s. we've got a python/django job opening. Just a few days left, though. See my previous blog post.) -
Django Requirements 2012-08-15
A little over three months ago I blogged about my preferred requirements list. It's now nearly the eve of Django Dash, and I feel it's time to update the list. I'm going to bump the versions on some of the existing packages and add some new ones to the list. New Packages django-braces==0.1.3 Want to use Django Class Based Views but unhappy with the missing components like LoginRequiredMixin, SelectRelatedMixin, and even StaffuserRequiredMixin? Not to worry, as this library will make Django CBVs 134% easier to use. django-secure==0.1.2 Django is rather secure, but there is a checklist of things that the security experts want you to do. Save yourself forgetting something and use this library to do all those little things. django-profiletools==0.1.3 Have you ever used the django-debug-toolbar and noticed that you did that same request.user.get_profile() call a dozen times? Ever want to just call that once? This library, by yours truly, resolves the issue. It loads the user's profile object once, and then passes it down the request chain. Existing Packages Django==1.4.1 If you need sessions, forms, templates, and relational database models, then I can argue you've got the ideal Django project. Make certain you are running the latest Django … -
DjangoCon 2012 - Metro
The DC area has a commuter rail called the Metro. It's pretty easy to use in my opinion. Still, I've had to give enough impromptu lessons to tourists to know it's not completely intuitive. The Map Do yourself a favor and get a copy of the Metro's rail map now, whether you store it on your phone or in your backpack. They have one of these maps on every car and in every station, but sometimes people stand in front of them. Lines are indicated by color (that part should be intuitive). Stops are indicated by circles. If a stop appears on more than one line, then you can transfer there. Why are some of the stops double circles? Because they're the first or last place you can transfer to a new line. They're not the only places you can transfer. Any circle on any color (even those that run under two other lines of color) are transfer stations. For example, at L'Enfant Plaza you can transfer to orange, blue, green, and yellow lines. Something to keep in mind: The map is not to scale. Some stops, you can get off and walk to the next stop with no issues. … -
AJAX and Django Views
It seems that cleanly and easily doing AJAX views in Django is an area that gives a lot of people trouble. We like to do views as straight HTTP if at all possible, but there are always interactions that would be better served by not having a page load. We're also big fans of django-tastypie but it's a whole other ball of wax on its own, especially if you want to have views that write to the database. So, for the purposes of getting everyone up to speed doing AJAX with Django, we'll ignore Tastypie for now and just stick with ordinary views. Django automatic CSRF To start things off, put this bit of Javascript from the Django docs into a script that's loaded on all the pages where you'll be needing to perform AJAX views. This allows you to ignore the CSRF token for AJAX views, but it will be added as a request header. We previously said this could be seen as a security loophole and that same-origin came into effect. Both of these statements are wrong. AJAX & Form Field Errors Before we get to the Django side, there are a few small scripts that we recycle … -
Generic Layouts in Crispy Forms
Just a quick tip and sanity check, today, about something I ran into with django-crispy-forms, the awesome new form library from Miguel Araujo. This morning, I converted the project we've been building for a client (currently some 1,700 or so files, counting templates, CSS, and icons) from django-uni-form to django-crispy-forms. It's a pretty painless transition, actually. Just do some find-and-replace across your files, basically changing any instance of uni- to crispy- (well, and form to forms), and you're good to go. Then, however, I wanted to convert two large forms that we have, which share 90% of their fields, to using the sharable Layout objects that django-crispy-forms gives us. Basically, the forms looked like this: class FirstForm(GenericAppFormForTheExample): ... def __init__(self, *args, **kwargs): ... self.helper = FormHelper() self.helper.layout = Layout( "field1", "field2", "special-field", [field3 through field20] class SecondForm(GenericAppFormForTheExample): ... def __init__(self, *args, **kwargs): ... self.helper = FormHelper() self.helper.layout = Layout( "field1", "field2", "special-field2", [field3 thorugh field20] Obviously that was a lot of repetition that we could cut out now that these inheritable layouts exist. By the way, I'm pretty sure this would have been possible in django-uni-form but likely not as friendly. First I started off by creating the shared resources. … -
Our Custom Mixins
UPDATE: We've released a Github repo and a PyPI package with our mixins. Feel free to fork and submit new ones through a pull-request. Let's just start out and say it, Class Based Views. Ooohhhh. Unfortunately the topic of class based views is thought of as somewhat of a dark art in the Django community. It doesn't help that the documentation is still lacking but I find a lot of people, especially on Reddit, refuse to use them. For whatever reason, it's a hard pill for some to swallow. Before DjangoCon 2011, we started playing with class-based views. At first they seemed like a nightmare and without decent docs, we got frustrated really quickly. Skip forward to today and I can't imagine writing old function-based views again. Some argue that the generic views are only for generic applications and that, somehow, their work is far too custom and complex to be handled in a generic class-based view. Based on my experience, 99% of the time, they would be wrong. We plan on covering generic class-based views extensively with GSWD. Today, I'd like to share some mixins we have cooked up, on a rather large client project, that have helped us … -
User-friendlier model forms
Recently, in our large client project, we had need of fields, in a model form, that accepted multiple types of input, but sanitized the data for the model. For example, the rent field, on the form, needs to handle a rent range (e.g. 900-1200), a single amount, or be overridden or extended by other bits of information, like "call for details" or "on approved credit". Obviously we don't want to have to parse this out every time we read the data. So, enter our fields that tear data apart and put it together every time it passes through. Model Let's go over our Rent model first. It's an abstract model so we can use it in multiple places (we have more than one logical model in the system that needs to deal with rent, this way we can use it multiple places without having to hold on to a huge amount of joins). We have several other abstract models that perform the same actions as our Rent model, but I won't show them here. from django.core.exceptions import ValidationError from django.db import models class Rent(models.Model): rent_low = models.PositiveIntegerField() rent_high = models.PositiveIntegerField(blank=True, null=True) rent_percent_income = models.FloatField(blank=True, null=True) rent_oac = models.BooleanField(default=False) rent_call_for_details = … -
How to Setup an Upload Handler for Redactor
Yesterday, I posted about how I was having fun with redactorjs and promised to follow up with how to hook up the ability to upload and embed images. Well, I am pleased to be able to show you how with a few lines of Python and Django. Specifically, we are talking about how to hook up redactor so the image button on the toolbar presents a functioning modal like so: There are two parts to this dialog that we are going to hook up. First, the ability to upload an image, and secondly, the ability choose one that we have previously uploaded. The Model There is a single, super simple model to store the files that get uploaded. The boolean flag indicating whether or not the file is an image is for the support I am going to add to be able to upload regular files as well. It's probably best for me to store an inspected mimetype, but this should suffice for now in case I want to reuse these objects elsewhere in order to know how to display them. import datetime from django.db import models class File(models.Model): upload = models.FileField(upload_to="uploads/%Y/%m/%d/") date_created = models.DateTimeField(default=datetime.datetime.now) is_image = models.BooleanField(default=True) The Views There are two views …