Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Paginated feed for cmsplugin_feed
In my previous post [1] I wrote about my experience of writing a new plugins for django-cms [2]. This plugin gives you the capability to add a feed to a django-cms' Page.I ended my post by asking about the best practice used to paginate the content of a plugin. Since I didn't get flooded by the answers I assumed that this shouldn't be different than doing it on a django app. Here it is what the fine django documentation says about this topic.So I have decided to implement this approach, the key point here is to understand that django-cms' plugin has access to the context :class FeedPlugin(CMSPluginBase): [...] def render(self, context, instance, placeholder): feed = get_cached_feed(instance) if instance.paginate_by: is_paginated =True request = context['request'] [...]This capability lets your plugin react to the GET and POST parameters. Once I have understood this the only thing that I had to do is to use the django's Paginator on the list of feed entries. As you can see in the code below there is nothing specific to django-cms there. is_paginated =True request = context['request'] feed_page_param = "feed_%s_page" %str(instance.id) feed_paginator = Paginator(feed["entries"], instance.paginate_by) # Make sure page request is an int. If not, deliver first … -
Django, it's just Python.
'It's just python' A statement I've heard a number of Django people use. I happen to think its quite relevant and important to remember. Django is stupidly easy to get started with, you feel empowered when you make your first website and its amazing. You can do so much and you only need to write a few lines of code. At this point yes you are writing python, but, really your not. I'm talking Django tutorial level code, after completing that you wouldn't claim to being a python coder would you? Luckily after playing with Django for a bit I realised how great python is as a language and I chose to do my MSc Dissertation research with python - that was a great idea. It was my first real piece of python code without Django1 and I really struggled at first, it was only at this point that I ran into strange gotchas and silly things like circular imports that at the time confused me. Django really encourages a set layout and manages hooking it all together for you. I learned a lot in this project about python, it's by far the most profitable piece of work at university … -
Running django with daemontools
Running django with daemontools -
feed extension for django-cms
I have been lately looking at the open source CMS alternatives based on django. After some times investigating I have decided to give django-cms [1] a try.django-cms provides an API to write plugin it is well documented [2] and you can also look the implementation of plugins listed there [3]. I have decided to experiment with it by writing a plugin that displays the content of a feed into a page. The source code is available on my bitbucket account in a project called cmsplugin-feed. The development of this plugin has been relatively straight forward and once you get to know the conventions defined to implement an extension. You feel like you are writing python code for a django application. The CMS part does not stand on your way at least it didn't in my experimentation.Here it is 2 screenshots showing this plugin in action :In order to add a feed you need give a name and an URL to your feedThen the plugin displays the field on a page.I would be interested to read from someone the "best practice" to paginate the content of a plugin. Ideally I would like to add a parameter for every feed indicating how many items I … -
Using bpython shell with django (and some Ipython features you should know)
What is bpython? bpython is a fancy interface to the Python interpreter for Unix-like operating system. says the bpython home page. It provides syntax highlighting, auto completion, auto-indentation and such stuff. Unlike iPython, which implements then entire shell functions and emulates the standard python shell, and adds enhancements, bpython just adds features on top of [...] Related posts:Better Python package management using source and version control systems Tools of Pro Django developer – aka What powers dinette and almost every app we write. -
Using DHTMLXgrid in a Django application
DHTMLX grid is a complete grid solution for browsing and editing grid like, spreadsheet like data from various sources. This tutorial will show you how to connect server-side Django views with client-side xgrid features. -
Fixing PostgreSQL's default encoding on Ubuntu 9.10
Ubuntu 9.10 installs PostgreSQL with a default encoding of SQL_ASCII. This is dumb: SQL_ASCII basically means “I don’t care about the encoding of my data; just store garbage.” This is especially annoying since PostgreSQL will actually prevent you from creating new databases with a different encoding: if you try, you’ll be told that the “new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII).” My fix was to just blow away the default cluster and re-create it with a UTF8 encoding. -
YTM launch!!
No more beta for YouTellMe.nl The website which is taking over the Dutch product comparison market is officially going out of beta @ 8 o clock. Party in Amsterdam, Keizersgracht 182 :) Festivities starting right now! Things are going well, looking very forward to international launch. We’ve changed a lot since the first reviews! Beter pictures coming after the event [...] -
Using the jQuery Autocomplete Plugin with Django
Here’s another look into the development of ComicBinder. There’s already a good tutorial on how to use an autocomplete plugin with Django, but I wanted to use this much snazzier plugin. The Process Load both jquery.autocomplete.min.js and jquery.autocomplete.css in your page. In your form object, create a CharField to hold your autocomplete. Something like: title [...] -
Django Object Permissions Proof of Concept
In the process of refactoring an app, we realized that we needed a general purpose, object-level (or row-level) permission system. So we looked around and found two: django-authority and django-granular-permissions. Django Granular permissions was closest to what we wanted, but not as complete as Django Authority. We figured we could flush out Granular Permissions and all would be well. So one thing lead to another and it has morphed into something different. Because of the complexity of object-level or row-level permissions, we wanted to get feedback on the current proof-of-concept from the Web’s best and brightest: the Django developer community. First the code: on github.com For discussions, I created a public Google Wave, as it seems more appropriate than just comments on this blog or via e-mail list. Since I don’t know how to reference them any other way, search for django permission with:public. If some of you aren’t on Google Wave yet and want to comment, I do have some invites. Now my introduction to the code: There is documentation, although it is preliminary. There is a script build_docs.sh that will build it and put it into docs/_build/html if you have Sphinx installed. It walks you through assigning permissions on your own code, … -
Itchy Fingers
Last night after I got home from techmeetup I had itchy fingers, the domain transfer had finally came through so I went for it. I flipped the switch. My new website and sitesprint effort is now officially launched! I'll be doing a full post-mortem of the sitesprint development after its finished as I hope to do a few more final tweaks on things. Please let me know if you have any feedback or comments - I really appreciate and enjoy getting feedback from my visitors. -
South migrations with MPTT
We've been using django-MPTT at work for quite a while. It's a great way to manage hierarchical data in a read-efficient way, and we use it heavily in our CMS application. I'll definitely be talking about it further in future posts. Recently we moved our database migrations from our defunct dmigrations project to Andrew Godwin's wonderful South application. One of South's best features is the ability to 'freeze' the ORM within each migration, so that you can manipulate the db via the familiar Django syntax rather than having to deal with raw SQL. However, we ran into a problem when trying to use this to add new instances to a model that uses MPTT. We're actually using Ben Frishman's fork of django-mptt, which he wrote while he was working for us this summer. This has a base model class that defines all the MPTT fields and methods, rather than monkey-patching them in as the original version does. The issue was that the frozen ORM only includes the basic fields that are defined on the actual model. This led to trouble when inserting a new object, especially when it's in the middle of an existing tree. MPTT includes values which identify … -
South migrations with MPTT
We've been using django-MPTT at work for quite a while. It's a great way to manage hierarchical data in a read-efficient way, and we use it heavily in our CMS application. I'll definitely be talking about it further in future posts. Recently we moved our database migrations from our defunct dmigrations project to Andrew Godwin's wonderful South application. One of South's best features is the ability to 'freeze' the ORM within each migration, so that you can manipulate the db via the familiar Django syntax rather than having to deal with raw SQL. However, we ran into a problem when trying to use this to add new instances to a model that uses MPTT. We're actually using Ben Frishman's fork of django-mptt, which he wrote while he was working for us this summer. This has a base model class that defines all the MPTT fields and methods, rather than monkey-patching them in as the original version does. The issue was that the frozen ORM only includes the basic fields that are defined on the actual model. This led to trouble when inserting a new object, especially when it's in the middle of an existing tree. MPTT includes values which identify … -
Customising Mingus, part 2
This is intended to be primarily a technical blog, so I was keen to get the presentation of code snippets correct. I'm a - shall we say - fairly frequent answerer on StackOverflow, and I've got used to their Markdown-enabled edit box. Luckily, the Mingus basic-blog application allows a choice of markup for body text, and even defaults to Markdown. But as always there were quite a few things to improve. Firstly, I do like StackOverflow's dynamic WYSIWSYG preview of the marked-up copy. Although Markdown syntax is quite simple, it's easy to get it wrong - using a three-space indent rather than four for code, for example. An instant preview just underneath the text entry field in the admin form is very useful. SO does it using the showdown.js library, which is part of their port of the 'what you see is what you mean' markdown editor, WMD. It was as easy to integrate the whole of WMD as just the preview, by adding a mingus\admin.py like this: from django import forms from django.conf import settings from django.contrib import admin from django.utils.safestring import mark_safe from basic.blog.models import Post from basic.blog.admin import PostAdmin class WMDEditor(forms.Textarea): def __init__(self, *args, **kwargs): attrs = … -
Customising Mingus, part 2
This is intended to be primarily a technical blog, so I was keen to get the presentation of code snippets correct. I'm a - shall we say - fairly frequent answerer on StackOverflow, and I've got used to their Markdown-enabled edit box. Luckily, the Mingus basic-blog application allows a choice of markup for body text, and even defaults to Markdown. But as always there were quite a few things to improve. Firstly, I do like StackOverflow's dynamic WYSIWSYG preview of the marked-up copy. Although Markdown syntax is quite simple, it's easy to get it wrong - using a three-space indent rather than four for code, for example. An instant preview just underneath the text entry field in the admin form is very useful. SO does it using the showdown.js library, which is part of their port of the 'what you see is what you mean' markdown editor, WMD. It was as easy to integrate the whole of WMD as just the preview, by adding a mingus\admin.py like this: from django import forms from django.conf import settings from django.contrib import admin from django.utils.safestring import mark_safe from basic.blog.models import Post from basic.blog.admin import PostAdmin class WMDEditor(forms.Textarea): def __init__(self, *args, **kwargs): attrs = … -
DjangoSki Registration is now open
Registration is now open for DjangoSki. Early bird tickets are on a simple first come, first served basis and registration is here. With our three keynotes set up and all the hairy contracts signed away, all that's left for us to do is plan the rest of the conference. And let it snow, snow and snow so that we've got a good base of snow ready for the conference. The next date to worry about is in about 3 weeks time, which is the deadline for any scheduled talks. We've got a couple of interesting case study talks lined up and still looking for some good introductory talks eg: Introduction to Django, Pinax, Django-CMS and so on. Been putting quite a few posts about DjangoSki up, sorry about that. It's very exciting for me and been quite a bit of work. Normal business of ignoring the blog and going back to Twitter will resume shortly. -
Python metaclasses and how Django uses them
Foss.in is without doubt India’s largest FOSS technology conference. Lakshman gave a talk today on “Python metaclasses and how Django uses them”. Here are the slides from that talk. Doing magic with python metaclassesView more documents from Usware Technologies. [Edit] Some reactions, http://twitter.com/jaideep2588/status/6295483833 http://twitter.com/kunalbharati/status/6296572939 And the talk images, http://twitpic.com/rxhn7 You should follow us on twitter [...] Related posts:The magic of metaclasses in Python Beginning python Better Python package management using source and version control systems -
Django quiz
A quick django quiz. Answers available tomorrow. Get it as a text file (django-quiz) or on google docs or read below. ### Easy 1. You have a class defined as class Post(models.Model): name = models.CharField(max_length=100) is_active = models.BooleanField(default=False) You create multiple objects of this type. If you do Post.objects.get(is_active=False), what exceptions is raised? a. MultipleObjectsReturned [...] Related posts:Doing things with Django forms Understanding decorators Using subdomains with Django -
Project Documentation
Currently I am in the process of passing down my project to some juniors and I find the need to document it. Me being the lazy ass programmer that I am obviously started to look for something that would allow me to complete my documentation in as least steps and most painless way as possible. Found two main applications that I am using now:1. Sphinx -> For main documenting work.2. Happydoc -> For parsing and generating code documentation. Both are quite easy to use and allows documentation to be generated in various format, which includes latex, html or pdf. Nice thing is both supports rest type reStructured text formatting which I just absolutely adore and is great to work with. I am especially impressed with Sphinx and the beautiful documents generated by Sphinx, coming with it's own search and everything. It's just what the lazy programmer doctor ordered. I am still evaluating both of these programs and am still open to other choices but so far these fit the bill nicely. -
Matt Berg keynote, call for speakers for DjangoSki
For our final keynote I'm pleased to say that Matt Berg will be speaking at DjangoSki. Matt Berg is the ICT Coordinator on the Millenium Villages Project at Columbia University. As part of that project he's been building technical systems in developing countries. He's involved with RapidSMS and projects include work in Kenya, South Senegal, Malawi and Rwanda that help children with malaria and malnutrition. And it's all using open source software and Django. Not only does Matt do interesting work that is helping people right now, but he passionately believes that he can use Django and other technologies to make a difference. His passion and dedication is infectious, as you'll find out. We have room for other speakers at the conference, so we'd like to call for other speakers to submit proposals to speak at the conference. Please apply here or see details here. -
Smart URL Redirects in Django
While building ComicBinder‘s URLs, I wanted a way to differentiate a volume of a title other than one, and a printing of an issue other than one. So, for example, a URL to the second printing of the second volume of Amazing Spider-Man #1 would look like: /marvel/amazing-spider-man_2/1_2/ That’s easy enough with some URLconf wrangling. [...] -
Jacob Kaplan-Moss keynote at DjangoSki
We are excited to announce that Jacob Kaplan-Moss will be giving one of the keynote talks at DjangoSki. It's almost impossible to be around Django and not know who Jacob is. He's one of the original founders of Django, is on the foundation board, is the co-BDFL of Django and is the co-author of The Definitive Guide to Django. Let's face it, if it's got something to do with Django, Jacob has had some influence on it. Currently Jacob works at Revolution Systems where he gets to do lots more Django. After missing Jacob at DjangoCon in Portland, it will be certainly good to have him around in Whistler. Perhaps even get some sprinting on Django 1.2 (which will be out a few days after DjangoSki). Jacob writes a great blog and is a great speaker. -
uWSGI reaches the 0.9.3 Milestone
uWSGI project [1] reaches the 0.9.3 milestone. You can review the complete announcement [2] on the mailing list and download the code here [3]This new release brings some new exiting features :- Nginx 0.7.x module- configuration via python module- support (non-standard) for Python 3.x- Twisted client resource adapter- graceful restart of worker processes and hot-plug substitution/upgradeof the uWSGI server- shared memory area to share data between workers/processes- Tomcat handler- support for virtualenvIn this post [4] I have covered the usage of both the "configuration via a python module" and the "virtualenv support".uWSGI allows you to run your favorite wsgi application on top of prefered web server (apache, cherokee or nginx).[1] http://projects.unbit.it/uwsgi/[2] http://lists.unbit.it/pipermail/uwsgi/2009-November/000020.html[3] http://projects.unbit.it/downloads/uwsgi-0.9.3.tar.gz[4] http://yml-blog.blogspot.com/2009/11/setting-up-django-project-with-cherokee.html -
8 Books To Get A Developer For The Holidays
Send this to your significant other/parent/relative/friend so, instead of that sweater, you get one of these nuggets of awesome this Christmas. The Pragmatic Programmer: From Journeyman to Master Write better, cleaner, more maintainable code. Learn how to manage your projects and focus on shipping your product. With insight that covers the gamut of software development [...] Related posts:Be Language Agnostic – Solve the Problem! Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger Django 1.0 Template Development: Sample Chapter “Serving Multiple Templates” -
Should you go with Google App Engine?
Recently I responded to the question on Stack Overflow about wether Google App Engine is worth it, over conventional hosting providers for typical databased-backed setup. I will not recite all the pros and cons of App Engine as I already did that in my answer, but I would like to focus on one interesting aspect of Google App Engine where it wins big time over conventional hosting approaches. In particular - the deployment process. Let's get started... Deploying on regular hosting environment How do you deploy a web application (like Django for example) to an Apache-backed hosting server? Well there are a few steps you have to take: FTP or SCP your applicaton to the server Replace the folder with the new folder Stop the server, services etc.. Start the server services etc... BONUS: Modify your databse schema Of course if you are proper developer you might simplify you deployment process and also make use of revision control system. You can also write a script to automate the deployment process, in particular for steps 3-5: Commit your code to revision control, possibly marking it with a tag for Release or Deployment. Log onto your producton server Check out the code …