Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
- 
        Custom app names in the django adminEDIT: This approach is flawed - it will never work in the app_index page (/admin/appname/) and can cause problems with contenttypes queries. You are better off overriding the admin templates (lots of them unfortunately). To avoid hardcoding the app_label in the templates wrap it in trans tags and use the internationalization framework to map the internal name to your desired display name. EDIT 2: You can also use this. Suppose you have a model like this: class Stuff(models.Model): class Meta: verbose_name = u'The stuff' verbose_name_plural = u'The bunch of stuff' ... You have verbose_name, however you want to customise app_label too for different display in admin. Unfortunatelly having some arbitrary string (with spaces) doesn't work and it's not for display anyway. Turns out that the admin uses app_label. title () for display so we can make a little hack: str subclass with overriden title method: class string_with_title(str): def __new__(cls, value, title): instance = str.__new__(cls, value) instance._title = title return instance def title(self): return self._title __copy__ = lambda self: self __deepcopy__ = lambda self, memodict: self Now we can have the model like this: class Stuff(models.Model): class Meta: app_label = string_with_title("stuffapp", "The stuff box") # 'stuffapp' is the name of the …
- 
        Custom app names in the django adminEDIT: This approach is flawed - it will never work in the app_index page (/admin/appname/) and can cause problems with contenttypes queries. You are better off overriding the admin templates (lots of them unfortunately). To avoid hardcoding the app_label in the templates wrap it in trans tags and use the internationalization framework to map the internal name to your desired display name. EDIT 2: You can also use this. Suppose you have a model like this: class Stuff(models.Model): class Meta: verbose_name = u'The stuff' verbose_name_plural = u'The bunch of stuff' ... You have verbose_name, however you want to customise app_label too for different display in admin. Unfortunatelly having some arbitrary string (with spaces) doesn't work and it's not for display anyway. Turns out that the admin uses app_label. title () for display so we can make a little hack: str subclass with overriden title method: class string_with_title(str): def __new__(cls, value, title): instance = str.__new__(cls, value) instance._title = title return instance def title(self): return self._title __copy__ = lambda self: self __deepcopy__ = lambda self, memodict: self Now we can have the model like this: class Stuff(models.Model): class Meta: app_label = string_with_title("stuffapp", "The stuff box") # 'stuffapp' is the name of the …
- 
        Announcing django-uni-form 0.8.0 beta!This has been a long time coming, but I am pleased to announce the release of the django-uni-form 0.8.0 beta. We plan to release the 0.8.0 final next Friday around the start of July 2011.This is an enormous jump forward in the project, and I think you'll like what has been done and who contributed.Some notable changesAs of this release, there is now a formal django-uni-form release on PyPI that fully supports Django CSRF tokens.Better error messages to help you debug. No more annoying Null messages on bad helpers!The Python code has been carefully cleaned and optimized. Much easier to read, debug, and it plain runs faster on form heavy sites.Various improvements to the templates to better match the parent Uni-Form library.Only compatible with Django 1.2 or higher and Python 2.6 or higher. If you need something to work with other earlier versions of Django/Python, then I suggest using django-uni-form 0.7.0. Or better yet, upgrade your site!Much improved documentation on the awesome readthedocs.org site.Tons of other things!Upcoming faster release cycles. More on that in the next section...Leadership change for django-uni-formLet's face it, over a year between releases is too long for any active open source project. I haven't done the incredible …
- 
        Running Django, Rails and Mojolicious on Windows Server 2008 with IIS 7Recently released  Helicon Zoo is a repository of popular web frameworks for Microsoft IIS. It makes installing and running Django, Ruby on Rails and Mojolicious on Windows Servers a piece of cake. THIS ARTICLE IS OUTDATED Please read following articles to find information how to run Django, Rails and other popular web engines on IIS: Running Django on Windows (with performance tests) Node.js on Windows (with performance tests) Ruby on Rails on Windows in production Deploying Java Servlet applications on Windows with IIS Running Railo on IIS in production And you can find usage examples for various web engines on a usage page. How it works Helicon Zoo utilizes Microsoft Web Platform Installer (WebPI) to make installation of web frameworks and all required dependencies easy and smooth. At first, you need to download and install WebPI from Microsoft web site here. This is a great tool that is already packed with many ASP.NET and PHP applications and dependencies to install a whole technology stack on your server. And the greatest thing about WebPI is that it can be extended by adding custom repositories. So copy this link - http://www.helicontech.com/zoo/feed/, open WebPI options put it into the Display additional scenarios field …
- 
        EuroPython
- 
        Django at Scale slides
- 
        Backing up your databaseLet me start by saying that there are MANY ways to backup databases and this might not be the absolute best way, but it definitely works. I’m backing up my PostgreSQL database that happens to be populated by Django, but you can muck with things as you see fit. So, one of the decisions I had to make is whether to save a representation of the data or to just dump the database data itself. The first option would be something like this: python manage.py dumpdata --format=yaml Second option is to talk directly to the database. The benefit of this option is you get everything about the database in its current setup. Let’s say you made some changes to the schema directly within PostgreSQL. If you dumped the data into YAML or JSON you wouldn’t get those changes to the database itself. So it’s probably prefereable to go straight to the DB like so: pg_dump <DATABASE NAME> What I ended up with is a nightly backup on the database server. Then I pull that data from onto a second server using rsync.   Steps it took: 1. Setup e-mail sending, so that I get cron e-mails. $ sudo apt-get install …
- 
        Django Facebook 2.0 – Integrating FacebookIt’s been a year since Facebook changed the web with the open graph API and their like button. Unfortunately Facebook didn’t have much developer love for the python/django platform. Django Facebook aims to make it easy to build facebook apps and integrate facebook with your website. Key functionality One of the strong points of Django Facebook is the ability to register users using Facebook. It ports all of Facebook’s user data to the Django user and profile models. This allows you to have a secure register/connect/login flow using Facebook, greatly reducing the barriers to start using your application. Below an example of me registering for Fashiolista using the Facebook register flow. Me on Facebook Me on Fashiolista In this blog post I will explain how to get started implementing a Facebook connect flow. Django Facebook can however do quite a bit more, as you can see in the feature list below. Development over at the github repo is very active. I strongly appreciate help on improving the functionality so please fork and contribute. Features Register users using the Facebook open graph API Full profile data birthday, gender, website, about me, username, email and picture Support for mobile authentication Fallback to …
- 
        Django Libraries for XML and eXist DBWe often use XML at Academic Libraries and decided to create a set of libraries to ease our work connecting our XML and repository based work to the Django framework by building a central set of libraries.  We'll be continuing to build these libraries out and recently released the code as open source projects on GitHub. EULxml provides XPath parsing features in python and mappings for xml documents to pythonic objects as well as features to provide Django Form to simple XML objects.  The code is available on GitHub and some documentation and examples up on read the docs.  EULexistdb provides connections and XQuery capability to eXist DB and Django Queryset like objects for rich interaction between Django and XML data stored in eXist DB.  Combined with the XML Django Forms from EULxml (on which it depends) it has enabled us to do a lot with our Library collection.  This library is also available on GitHub and has some documentation and examples up on read the docs. We're excited at the possibilities of leveraging the power of Django with our XML databases and repositories.   We're open sourcing it in hopes others may find it useful and may want to contribute …
- 
        Django: Logging Quickstart in Django 1.3Logging is always one of those things that seems like there is a lot of boilerplate code that I tend to always have to lookup oneline each time.  Though logging is very customizable, most of the time I need simply to only need log to a file or files.   Therefore, I'm writing this in hopes of compling a simple configuration that can be dropped into a project.  My understanding is still rudimentary so feel free to drop a comment.A logging framework is built into Django 1.3 which makes it easier to integrate into a given project.  The logging framework contains three main components: formatters, handlers, and loggers.  Formatters determine how the output will be displayed when it is logged.  Handlers handle where output is logged, whether that be a file, the counsole, or an email.  Loggers are associated with handlers and are the objects that one interacts with when logging something.  As in the example below, more than one formatter, handler or logger can be defined in a project. In settings.py:import os# choose a path that is your virtual environment rootVENV_ROOT = os.path.join('/','web','myvenv')LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' …
- 
        Resetting Your South MigrationsA common question from South users is how to reset the migrations back to an initial state. The reasons for doing this are often related to the number of migrations growing steadily over the life of the project. You’ve probably noticed that tests and parts of your workflow are bogging down while waiting for a bunch of migrations to run. In practice it is rare that you’ll have a need to roll back to an early version of a model that is potentially dozens of migrations back in history. Therefore, the idea of resetting your South migrations is worth examining when deciding how to manage your project history long-term.
- 
        Shiv - A wrapper over DjangoI joined LazyZach as the first hire back in 2009. I was already in love with Python by then and when it came to deciding which technology to use, the answer was quite obviously, Django. While Django does speed up development, I wanted something a bit more streamlined to my thought process. Having my “views” all over the place was definitely not the way I wanted to go. Plus, there was a need for a more clear separation of back end and front end tasks (I was, and still am, a bit weary of all the html and css stuff that goes around). All this and some more made me develop Shiv, a thin wrapper over Django. For all those Django noobs out there, one thing I wish to say is that “Django is Python”. Realize this, and life will be so much simpler for you. And yes, do not go about learning Django, learn Python and you will know Django inside out. In this post, I will discuss the basic idea behind Shiv. Other key features and benefits like AJAX handling, Widgets, auto JS/CSS minimization, will be discussed in later posts. Coming from a non-web dev background, the way …
- 
        Introducing django-peavyContinuing my apparent obsession with logging, I've just released django-peavy. It's a collection of logging support code for capturing your Django application logging to a database, and a (really) basic user interface for reviewing it. Notable features include: Middleware to tag each request with a unique ID. Logging filters to capture request metadata like user, remote IP, and headers. Logging handlers for: Capturing exception information, including a copy of the Django server error page, in a database. Sending error notifications to admins without revealing sensitive information like the contents of request.POST. A database router for sending log records to a separate database (though there are problems with South migrations you'll need to work around to do so). A simple user interface for browsing log records in the database.
- 
        Un creant bits d'estiuFa just una estoneta he fet l'anunci per Twitter de que ens han confirmat des del Parc Bit que podem disposar de la sala de formacio pel #creantbits el dia 15 de juliol a les 16:00. Aprofitant que és estiu i fa molta calor, i la gent tampoc està per xerrades molt llargues, hem pensat que estaria bé fer xerrades curtes i d'un bon grapat de temes. La primera per anar fent boca serà de Python. Una introducció als nousvinguts en aquest llenguatge que serveixi per perdre-li la por. En una horeta es pot veure bastant bé el llenguatge i tenir un idea suficient per poder seguir la resta de xerrades, o al manco per adonar-se de la potència que s'amaga darrera el llenguatges. Després en @morenosan ens parlarà mitja horeta de South i de les seves possibilitats quan fas desenvolupaments amb Django. South ens permet fer modificacions a la nostra estructura de base de dades, de manera que passar de desenvolupament a preproducció i després a producció sigui poc traumàtic, de fet per a que sigui gairebé automàtic. Per la gent que no ha fet servir mai una eina com aquesta segur que serà una revel·lació. Mirarem que @bercab …
- 
        Django AuthenticationForm For User LoginDjango already makes it insanely easy to log a user in and out via their generic views.  Engineers will often want to create their own login view to provide some flexibility, say an Ajax login or other spin on standard login.  A number of examples are given in Django for that as well, and as with most of the framework this is a snap too.  A convenient feature of Django that doesn't make it into many of the examples I've seen is the AuthenticationForm that provides a convenience Django form with associated logic render a login form, validate input and throw errors if they do things like forget to supply a password and do the basic authentication check. The form provides that all for you and all you really need to do in your view is read the user submitted data, validate the form and take the final step of logging the user in. This is just one form in a group of 7 or so that provide all kinds of convenience features like Password Changes and User Registration.  Not only do they provide a developer with very easy access to common functions but they can extended or subclassed like …
- 
        Mobile API Design - Thinking Beyond RESTThis article explores the problems of optimising REST APIs for mobile device performance, and suggests a way of allowing clients to request alternate representations.
- 
        Mobile API Design - Thinking Beyond RESTNate Aune and Anna Callahan gave a great talk at this year's EuroDjangoCon about a service that they'd built in 24 hours, valentun.es. Along with a great story, the meat of the talk was about the concessions you have to make with a mobile API with respect to data transfer rates and connectivity. Some of the things they said struck a chord with my own experiences of designing mobile APIs, and inspired me to write this post about those experiences, principles, problems, solutions - and an idea for the future. What's a REST API? There are probably as many definitions of what a REST API is as there are implementations (so naturally I'll add my own), but they all share some common characteristics: They recognise that the web is composed of resources, and are structured around that They use the underlying HTTP methods (GET, POST, PUT, DELETE) to interact with resources Representations of those resources are what actually flow back and forth between REST API servers and clients URIs (usually URLs, which I'll use for the remainder of the article) are used to identify application state - particularly information on what the client can do next - andis contained within …
- 
        Mobile API Design - Thinking Beyond RESTNate Aune and Anna Callahan gave a great talk at this year's EuroDjangoCon about a service that they'd built in 24 hours, valentun.es. Along with a great story, the meat of the talk was about the concessions you have to make with a mobile API with respect to data transfer rates and connectivity. Some of the things they said struck a chord with my own experiences of designing mobile APIs, and inspired me to write this post about those experiences, principles, problems, solutions - and an idea for the future. What's a REST API? There are probably as many definitions of what a REST API is as there are implementations (so naturally I'll add my own), but they all share some common characteristics: They recognise that the web is composed of resources, and are structured around that They use the underlying HTTP methods (GET, POST, PUT, DELETE) to interact with resources Representations of those resources are what actually flow back and forth between REST API servers and clients URIs (usually URLs, which I'll use for the remainder of the article) are used to identify application state - particularly information on what the client can do next - andis contained within …
- 
        Mobile API Design - Thinking Beyond RESTNate Aune and Anna Callahan gave a great talk at this year's EuroDjangoCon about a service that they'd built in 24 hours, valentun.es. Along with a great story, the meat of the talk was about the concessions you have to make with a mobile API with respect to data transfer rates and connectivity. Some of the things they said struck a chord with my own experiences of designing mobile APIs, and inspired me to write this post about those experiences, principles, problems, solutions - and an idea for the future. What's a REST API? There are probably as many definitions of what a REST API is as there are implementations (so naturally I'll add my own), but they all share some common characteristics: They recognise that the web is composed of resources, and are structured around that They use the underlying HTTP methods (GET, POST, PUT, DELETE) to interact with resources Representations of those resources are what actually flow back and forth between REST API servers and clients URIs (usually URLs, which I'll use for the remainder of the article) are used to identify application state - particularly information on what the client can do next - andis contained within …
- 
        Avaluant GondorEstic a la segona tongada de beta-testers de Gondor un hosting per Django montat al núvol desenvolupat per la gent d'Eldarion. L'aplicació vol simplificar la manera de desplegar les aplicacions Django a força de forçar una determinada configuració. És a dir, es simplifica el desplegament, però sempre que juguem amb les cartes que ens donen, que he de dir que no són dolentes. La posada en marxa és senzilla, el programa que fa la interacció amb Gondor (una vegada t'has donat d'alta a la web) és un paquet que està al PyPi, així que és sols cosa de pip install gondor i gairebé ja pots començar a fer-hi feina. Per provar he fet servir un codi que ja tenia mig fet i que ara s'ha convertit en la web d'inscripcions de creantbits. La conversió d'una aplicació tal com la desplegam a APSL habitualment a una aplicació capaç de ser desplegada amb Gondor és prou senzilla, i està ben explicada a la documentació. Si més no però, convé fer uns petits avisos per si algú també s'hi troba: El teu projecte ha de ser gestionat per Git o Mercurial. Tant fa si no hi ha un repositori remot, però s'ha de …
- 
        django-dtpanel-htmltidy: Custom Django Debug Toolbar panel to validate your HTMLCustom panel form Django Debug Toolbar which display HTML Validation errors and warnings.Install with PIP:pip install django-dtpanel-htmltidyConfiguration instructions on githubCompatible with Django 1.1.1 and higher and Django Debug Toolbar 0.8.2 and higher.Preview:App on:PyPI: http://pypi.python.org/pypi/django-dtpanel-htmltidy/0.1.1Github: https://github.com/joymax/django-dtpanel-htmltidyThanks to Rob Hudson and Enrique Bastos for the tip about custom panel.
- 
        Django gets support for IPv6 fieldsMy favorite web development framework recently committed some code to add support for IPv6 addresses in data models. The commit closes a ticket I opened 6 years ago. Congratulations to Erik Romijn for finally closing this off. Better late than never :) The new code differs from my original code in a number of ways. First of all it has better testing and documentation. Second, it does IPv6
- 
        Django Tempate Tag for Gravatar ImagesGravatar images seem to be growing in popularity across a number of sites and the services already makes it incredibly simple to grab a profile picture there via URL.  The Gravatar site itself has a number of examples on how to grab an image off of the service, as well as more detailed examples of grabbing more information. They do provide a examples for grabbing an image via Python and even a Django example which renders the image as a template note.  For displays like this I generally prefer an inclusion tag since I can render the image in a template rather than having to build it each time on my own. The template tag itself is just: from django import template import urllib, hashlib from yourapp import settings # Provide Default settings so users only need to provide them in settings.py if they want to override. GRAVATAR_BASEURL = getattr(settings, "GRAVATAR_BASEURL", "http://www.gravatar.com/avatar/") GRAVATAR_DEFAULT_IMAGE = getattr(settings, "GRAVATAR_DEFAULT_IMAGE", "") GRAVATAR_SIZE = getattr(settings, "GRAVATAR_SIZE", 40) register = template.Library() def gravatar_url(email, size): """ Builds a Gravatar Image URL based on the provided email. :param email: Email address to query for a gravatar image. :param size: Size to request and render the image in pixels. """ attrs …
- 
        Dynamic fields inside a form do not get postedI was struggling for a bit today with dynamically creating form fields using Jquery. Whenever I was posting the form the dynamic fields were not being sent over to my Django view. After some hair pulling (and scratching!) the answer came from moving the form field inside of the table to outside of the table.
- 
        Djangopeople.meWhat is it? At it's core, djangopeople.me is a place for Django developers to register and be found based on their geographic location, whether it's by recruiters or a lonely Django developer like ourselves trying to find others close to him/her. That's the general idea behind the site. We wanted to make it clean, simple and fast. For the maps we ended up using Leaflet's open-source Javascript library. We initially started with Google Maps, but the rate limiting was too restrictive on the geocoding API for our needs and frankly, loading maps seemed very slow. So, with the project being free-to-use (and us being cheap), we looked for something else. Yahoo! Maps was the next step as they had a decent API and allowed more requests. Google currently allows 2,500 requests per day and Yahoo allows 5,000 requests (geocoding). Yahoo's maps were faster to load but we seemed to have nothing but issues with Google Chome throwing a YMAP Javascript error we could never track down. We didn't think it would be all that awesome telling Chrome users to clear their cache up to three times before the maps would load again (If you've had this issue and a have …