Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Customising Django-Mingus
This blog is built using Kevin Fricovsky's excellent django-mingus project, which is mainly a set of standard pre-existing reusable apps with some templates and a bit of glue to hold it together. Although it's quite usable out of the box, I found - inveterate hacker that I am - that there were several things that I didn't quite like in the project as it was. So I changed them (isn't open source great, laydees-n-genelmen). At some point I'll fork the project on github and upload the changes, but for now here's what I've done. Firstly, mingus forsakes Django's built-in comments framework for the external Disqus project. I didn't really fancy signing up for another service - especially as I'm not expecting vast numbers of comments on this blog. It's quite a simple matter to reinstate the comments - the relevant template code is included in the post_detail.html template included with the basic-blog app which mingus extends, so I just needed to copy and paste it into the mingus version. Then add (r'comments/', include('django.contrib.comments.urls')), to urls.py, django.contrib.comments to settings.py, run a syncdb and it's all done. There are however a couple of missing pieces here. basic-blog doesn't include templates for the … -
Customising Django-Mingus
This blog is built using Kevin Fricovsky's excellent django-mingus project, which is mainly a set of standard pre-existing reusable apps with some templates and a bit of glue to hold it together. Although it's quite usable out of the box, I found - inveterate hacker that I am - that there were several things that I didn't quite like in the project as it was. So I changed them (isn't open source great, laydees-n-genelmen). At some point I'll fork the project on github and upload the changes, but for now here's what I've done. Firstly, mingus forsakes Django's built-in comments framework for the external Disqus project. I didn't really fancy signing up for another service - especially as I'm not expecting vast numbers of comments on this blog. It's quite a simple matter to reinstate the comments - the relevant template code is included in the post_detail.html template included with the basic-blog app which mingus extends, so I just needed to copy and paste it into the mingus version. Then add (r'comments/', include('django.contrib.comments.urls')), to urls.py, django.contrib.comments to settings.py, run a syncdb and it's all done. There are however a couple of missing pieces here. basic-blog doesn't include templates for the … -
Using Zoho remote API to edit office documents in a Django app
An introduction to Zoho.com APIs, CloudSQL, and sample usage of Remote API to edit documents, slides and sheets on a Django powered website. Full source code of the app included. -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and the Installation and Requirements page. Feel free to download and comment it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Django training and 'Last page visited' middleware
I've been lucky enough to have spent this week attending Jacob Kaplan-Moss's Django Training. One of the topics we covered a bit later in the week was middleware, which in the Django usage is somewhat of a misnomer. Middleware in Django allows you to pre-process requests, post-process responses, and handle exceptions. -
On Django and Check Constraints
I've come to love Django, and now I seem to be spending not only my work time, but also my own time working on one django project or another. Today at work I came across the need to have check constraints in a database. For instance, this can be used to ensure that the start of an event is before the end of the event, or that a certain value has a particular range of values. For the SQL savvy, it can look like: {% highlight sql %} CREATE TABLE event ( ...more columns here... start datetime, finish datetime, count integer CHECK (count >= 0), CONSTRAINT event_starts_before_finish CHECK (start < finish) ); {% endhighlight %} There are two types of constraint here: the column-level constraint, which in this instance can be done with django, and the table-level constraint, which in many systems cannot be a part of a column definition. In PostgreSQL, my DBMS of choice, it is possible to define a constraint that affects more than one column as part of a column, but I prefer not to. Note also that I am using the syntax form that allows me to name the constraint. This means I can alter … -
Django Fixtures
A fixture is basically a data dump in a specific format. There is no restriction of which models or how much data a fixture can contain. Fixtures are portable. They work the same with all the database backends and operating systems supported by Django. This means that you can use fixtures as a simple data [...] -
Moving from Django to Plone
This is the first of what might be a series of posts about learning Plone. I’ve worked in Django since January 2006, when Joe Heck, Karen Williams, and I built the now-defunct TrenchMice site. I haven’t done any Django work since March, when I joined Fisher Communications, but I’ve followed the mailing lists and blogs. And I [...] -
It Begins…
The country has just undergone a mass-exodus of university students from their parents' houses back into halls. I played by own small part in blocking up the roads moving back into university accommodation this weekend, and it's all gearing up for the new school year. I've been working with Django more and more lately, and [...] -
Add a web api to your app with django-piston
More and more often I found myself in a situation where I would like to add a web api to my django applications. I have recently tried to used django-piston http://bitbucket.org/jespern/django-piston for this and I found the learning curve a bit steep. It is not particularly hard but it requires you to understand few things before being able to enjoy it.This post should help you to understand how to create the handlers to read, create, update, delete an object and see how you can call this web api from the command line using curl. I have forked django-piston to extend the example "blogserver". I would recommend you to also read the README inside the exampleYou can grab the code like this :hg clone http://bitbucket.org/yml/django-piston/curl is a command line tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction.Here it is the 4 things that I found a bit hard to understand.1. @require_extendedThis decorator is handy if you want to restrict the access to your handler to only the request that have have one of … -
{% tree %}: деревья в Джанго-шаблонах
Буквально вчера ночью, вместо того, чтобы рисовать слайды для выступления на 404fest я как-то неожиданно написал кусок кода, который может кому-то ещё пригодиться. Это шаблонный тег и вспомогательный фильтр, которые умеют выводить в шаблон древовидные структуры в виде вложенных списков <ul> (вот таких, например). Несмотря на то, что изначально я написал его "неожиданно", потом долго сидел и боролся с не очень хотящей думать головой, чтобы на этот код не противно было смотреть. И я победил! Так что код теперь production-качества, что в переводе означает "уже один раз исправлялся". Тег {% tree %} На самом деле, в Джанге уже есть встроенное средство для вывода древовидных структур в список: фильтр "unordered_list". Но он не подошёл, потому что умеет выводить только строчки, а мне хочется в шаблоне как-то влиять на то, что лежит в отдельных <li>: ссылку сделать, дописать что-то. Поэтому я сделал тег, который работает так: {% tree some_list %} <a href="{{ item.get_absolute_url }}">{{ item }}</a> {% endtree %} Переменная "some_list" -- структурированное дерево в том же формате, что принимает и "unordererd_list" (кому лень было ходить по ссылке, это вот такое: ['item 1', ['subitem 1', 'subitem 2'], 'item 2', 'item 3]). Между открывающим и закрывающим тегами находится микрошаблон, который используется для одиночного … -
{% tree %}: деревья в Джанго-шаблонах
Буквально вчера ночью, вместо того, чтобы рисовать слайды для выступления на 404fest я как-то неожиданно написал кусок кода, который может кому-то ещё пригодиться. Это шаблонный тег и вспомогательный фильтр, которые умеют выводить в шаблон древовидные структуры в виде вложенных списков <ul> (вот таких, например). Несмотря на то, что изначально я написал его "неожиданно", потом долго сидел и боролся с не очень хотящей думать головой, чтобы на этот код не противно было смотреть. И я победил! Так что код теперь production-качества, что в переводе означает "уже один раз исправлялся". Тег {% tree %} На самом деле, в Джанге уже есть встроенное средство для вывода древовидных структур в список: фильтр "unordered_list". Но он не подошёл, потому что умеет выводить только строчки, а мне хочется в шаблоне как-то влиять на то, что лежит в отдельных <li>: ссылку сделать, дописать что-то. Поэтому я сделал тег, который работает так: {% tree some_list %} <a href="{{ item.get_absolute_url }}">{{ item }}</a> {% endtree %} Переменная "some_list" — структурированное дерево в том же формате, что принимает и "unordererd_list" (кому лень было ходить по ссылке, это вот такое: ['item 1', ['subitem 1', 'subitem 2'], 'item 2', 'item 3]). Между открывающим и закрывающим тегами находится микрошаблон, который используется для одиночного … -
Django Master Class, October 16
I’m pleased to announce that I’m teaming up with Steve Holden and Holden Web to teach a one-day Django Master Class. The class’ll be in Washington, DC on October 16th, 2009. I’ll be covering a grab-bag of advanced Django tricks, including AJAX, REST, schema migration, testing, caching, code quality, and more. Hopefully there’ll be something there for everything. For more info or to sign up, head on over to Holden Web -
Django 1.0 Template Development Review
Django 1.0 Template Development by Scott Newman actually surprised me in it's depth of covering the topic. I assumed it would be written with the absolute Django Template beginner in mind. While it is definitely an appropriate book for beginners, it also covers more advanced topics such as: Writing custom template tags and filters, Chapter 7 Covers pagination quite well in Chapter 8 Customizing the Django admin's look and feel in Chapter 9 And gives a good designer intro to caching in Chapter 10 This book should definitely be required reading for web designers that are looking to use Django. As someone who has read and re-read the wonderful Django Documentation many times this book does a great job of distilling all of that reference knowledge into book form. -
Contributor License Agreements
Mike Malone emailed me an interesting question, which I thought I’d answer publicly: [We’ve released code] under the BSD license. We want to accept patches from the community, but were wondering whether we need to get everyone who submits a patch to sign a release or something saying that their patch is BSD too. [Does Django] require everyone who submits a patch to sign that sort of release? The Right Way is to require that all contributors sign a contributor license agreement (CLA). -
Request for Comments: Auto-Installation of Apps in Django
The problem of pluggable Django apps Lately we’ve come across a bit of an issue with dependencies. We use pip and virtualenv for our projects and it works great for installing Python dependencies. However it is not so great if the dependency is a Django pluggable application. There is more you have to do: add all the dependent apps in INSTALLED_APPS and add the appropriate entry in your base urls.py. This can be a problem if you aren’t familiar with the app, let alone its dependent apps. Recently I used pip to test out what I thought was a stand-alone Django pluggable app, only to discover dependency after dependency. This isn’t very pluggable in my book. Proposal: A method of auto-installing apps The Django community has developed several patterns that make development easier. Many of them are related to how you configure the settings.py file for your project. See examples from Usware and this presentation from EuroDjangoCon. I’m proposing a new one, and would like assistance in refining it. A pluggable application would contain its own settings.py file containing one or more standard settings: APP_NAME, VERSION, and BASE_URL_CONF. In the project’s settings.py file, you would loop through one or more paths containing Django apps/Python packages. For each … -
Fabric factory
This is a project I have been working on recently after I spent a day to look at the existing solution to run periodically a test suite. Most of the project I look at were either difficult to setup or require to learn yet another specific domain specific language or had dependency on a larger software stack.As a reaction to this situation I have decided to see if I could write something simple that achieves gracefully this task. I also try to make it as easy to setup as possible. I have decided to use cpython as platform, django as web framework for the server and Fabric as library to automate the task execution.The result of this mix can be found on bitbucket in a project called Fabric Factory. This will eventually become a complete Job Server that could be used to distribute any kind of task scripted in Fabric.InstallationThis assumes that python is installed on your computer and that you have an internet conection.You can download the code using mercurial:* hg clone http://bitbucket.org/yml/fabric_factory/A fabfile will help you to quickly setup your environment.* fab quickstartNote : In order to run the command above you will need the latest version of … -
Evolution of an Auto-Complete
My latests hobby-project has been pushed live, in invite-only beta form. Previously known as Links Desktop, I have now dubbed it Loci Desktop, after the Loci Method. Auto-complete in Loci Desktop One feature of Loci Desktop is that it will auto-complete URLs when you add new icons to your ‘desktop’. Auto-complete is one of those features that users expect these days. They want the app to figure out what they want with as few key-presses as possible – and quite rightly so, typing is such a chore! The auto-complete system for Loci Desktop, in its initial state, was straight-forward to implement. The javascript and front-end was the most time-consuming part of the job, but the back-end Python code was trivial. Amoeba Alas, it was too slow to be practical. The list of URLs that I was auto-completing from came from a list of the top one million sites from Alexa.com, stored in MySQL and queried with the Django ORM. The query searched the urls for a substring, and sorted by the Alexa rank so the most popular sites were listed first. Although it worked perfectly, the auto-complete code at the back-end hammered the server and took to long to return … -
Evolution of an Auto-Complete
My latests hobby-project has been pushed live, in invite-only beta form. Previously known as Links Desktop, I have now dubbed it Loci Desktop, after the Loci Method. Auto-complete in Loci Desktop One feature of Loci Desktop is that it will auto-complete URLs when you add new icons to your ‘desktop’. Auto-complete is one of those features that users expect these days. They want the app to figure out what they want with as few key-presses as possible – and quite rightly so, typing is such a chore! The auto-complete system for Loci Desktop, in its initial state, was straight-forward to implement. The javascript and front-end was the most time-consuming part of the job, but the back-end Python code was trivial. Amoeba Alas, it was too slow to be practical. The list of URLs that I was auto-completing from came from a list of the top one million sites from Alexa.com, stored in MySQL and queried with the Django ORM. The query searched the urls for a substring, and sorted by the Alexa rank so the most popular sites were listed first. Although it worked perfectly, the auto-complete code at the back-end hammered the server and took to long to return … -
Evolution of an Auto-Complete
My latests hobby-project has been pushed live, in invite-only beta form. Previously known as Links Desktop, I have now dubbed it Loci Desktop, after the Loci Method. Auto-complete in Loci Desktop One feature of Loci Desktop is that it will auto-complete URLs when you add new icons to your ‘desktop’. Auto-complete is one of those features that users expect these days. They want the app to figure out what they want with as few key-presses as possible – and quite rightly so, typing is such a chore! The auto-complete system for Loci Desktop, in its initial state, was straight-forward to implement. The javascript and front-end was the most time-consuming part of the job, but the back-end Python code was trivial. Amoeba Alas, it was too slow to be practical. The list of URLs that I was auto-completing from came from a list of the top one million sites from Alexa.com, stored in MySQL and queried with the Django ORM. The query searched the urls for a substring, and sorted by the Alexa rank so the most popular sites were listed first. Although it worked perfectly, the auto-complete code at the back-end hammered the server and took to long to return … -
Early thoughts about Tornado, and what I might use it for
Today I tried out Tornado, the Python non-blocking web server optimized for speed & traffic. [Note: the confusing social media buzz around Tornado might make you think it includes social networking or twittering functionality. That's incorrect...just setting the record straight here.] Their chat demo seems pretty snappy, although I didn't see it under large loads or anything stressful. The long polling stuff is super-cool. You can start a request and leave it open for awhile, specifying a callback method to go to later. It's like ajax inside out and backwards. Testing out their framework...I like their blog demo. There's a Tornado-App Engine version, which I modified slightly to create a blog to keep track of my canvas experiments (totally unrelated, just killing two birds with one stone) Check it out: http://labs.fuzzyrainbow.com/graphicsexperiments/ [Note: if you're using Tornado with App Engine, you lose much of the functionality of Tornado that makes it interesting in the first place. WSGI doesn't support non-blocking requests. You'll want to use Tornado's own HTTP server.] Tornado comes with a really simple web framework along the lines of Google App Engine's "webapp" framework. I already like to use GAE+webapp for really simple projects, like basic API servers, and … -
Write your own ReStructuredText-Writer
Some time ago I decided to use ReStructuredText as the universal Format for nearly all content on my website. This includes not only all pages but also all blog entries like this one you are currently reading. Soon after I had implemented the Django backend for my website and started hacking together some HTML and CSS, I felt the need to manipulate the generated HTML from the docutils package. Don't get me wrong, theres nothing wrong with the HTML docutils created, but I'm a fan of very minimalistic but still semantic markup. Let me give you a few examples. While producing content for my website I make sure, that I only have one <h1> per page, which is the title of the page. Docutils creates the following HTML: <h1 class="title">Document Title</h1> But for me the extra class is redundant, because the h1 is unique on my pages. The output I want is: <h1>Document Title</h1> Doctils also wraps every section of the document into an extra div with an id to make it possible to provide anchor-links to specific sections. This is a nice-to-feature but I don't like it because it's not minimalistic, it creates to much extra-markup for me. Different …