Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Deploying Django projects
In the wake of `recent discussions `_ about deployment, I feel the need to tell you how easy my deployment has gotten using the old style tools like `nginx `_, `uwsgi `_, and `supervisord `_ on a dedicated (or VPS) server. Read on to find out how it stands the chance against the new online services such as `ep.io `_ or `DjangoZoom `_. -
Using Signals to Create User Profiles in Django 1.3
Django’s built-in User model is rather thin—deliberately so, since it’s designed to service a broad range of projects. If you burden your User model with additional fields and methods, you risk breaking compatibility with other Django apps or with future … Continue reading → -
Sprinting on Django: A Layperson's Perspective
We just got back from another fun and successful PyCon. While we didn't get to stay for much of the sprints we did get to spend some time in the Django sprint Sunday and Monday. Monday morning I was there early and I noticed a bit of confusion among the Django sprinters. While I'm not ... -
I become a PhD Student
I am happy to say that I successfully passed the entry tests for a PhD student. So now I am part of SULSIT(State University of Library Studies and Information Technologies) PhD program. The program`s name is “Automated Systems for Information processing and information management” and my thesis will be “Research of the current methods and [...] -
Using Dojo Rich Editor with Django's Admin
Many years ago I decided to replace plain text areas in Django's Admin with rich text editor, so I can edit HTML on my blog using WYSIWYG. Six (yes, 6) years ago I looked around and selected TinyMCE. Over time it turned out that I was forced to upgrade TinyMCE and the link script I had because new browsers continue breaking my rich editor editing. Finally it stopped working again in all modern browsers, and I decided that enough is enough. It is time to replace it. This time I settled on Dojo's Rich Editor hosted on Google CDN — simple, functional, less work to set up. Selecting features Adding Dojo's editor to Django's Admin was very simple. The most complex part turned out to be selecting what cool features I want to use. See, dijit.Editor is fully pluggable, and it is easy to extend with your own plugins. Some day I'll do just that, but for now let's use what's available. dijit.Editor comes with two sets of plugins. Let's go over them and select plugins we want to use. The first set is in Dijit's editor plugin repository: FullScreen: allows editor to take over the whole page. Toggleable. This … -
Using Dojo Rich Editor with Django's Admin
Many years ago I decided to replace plain text areas in Django’s Admin with rich text editor, so I can edit HTML on my blog using WYSIWYG. Six (yes, 6) years ago I looked around and selected TinyMCE. Over time it turned out that I was forced to upgrade TinyMCE and the link script I had because new browsers continue breaking my rich editor editing. Finally it stopped working again in all modern browsers, and I decided that enough is enough. It is time to replace it. This time I settled on Dojo’s Rich Editor hosted on Google CDN — simple, functional, less work to set up. Selecting features Adding Dojo’s editor to Django’s Admin was very simple. The most complex part turned out to be selecting what cool features I want to use. See, dijit.Editor is fully pluggable, and it is easy to extend with your own plugins. Some day I’ll do just that, but for now let’s use what’s available. dijit.Editor comes with two sets of plugins. Let’s go over them and select plugins we want to use. The first set is in Dijit’s editor plugin repository: FullScreen: allows editor to take over the whole page. Toggleable. This … -
New Job Posting: Linux Systems Administrator with Python/Django experience
I'm delighted to announce that we've just published another job posting for a Linux Systems Administrator at Caktus.  The position will involve maintaining existing Linux servers, designing and building highly-scalable deployments, and assistance with Django deployment and development as time permits.  This is a full-time position, with benefits, and is based out of our Carrboro, ... -
Solapament d'intervals ara amb Django
Segueixo amb la vena friki, ahir damunt el solapament d'intervals de mode genèric i avui veurem la implementació d'aquesta idea a un model Django. class Oferta(models.Model): """Una oferta que va per rang""" nom = models.CharField(max_length=200) inici = models.DateField() fi = models.DateField() activa = models.BooleanField(default=True) class Meta: verbose_name="Oferta" verbose_name_plural="Ofertes" def __unicode__(self): return self.nom El model com veis és molt senzill, una oferta pot estar activa o no i pertany sempre a un rang de dates. Queda fora de l'exemple la determinació de si admetem solapament de dates per una oferta, que es fareia de manera semblant al la cerca que ara farem. La idea és que hem d'aconseguir que amb l'ORM de Django nodelar una consulta del tipus not ((x1<y0) or (y1<x0)). Els filtres per defecte el que fan es un and, per la qual cosa no ens serveixen directament. El que farem és utilitzar una característica de l'ORM anomenada funció Q que ens permete afegir condicons de filtratge múltiples i fer que vaign per OR enlloc de per AND. from django.db.models import Q Ara sols queda fer la consulta. Particularment si són consultes que poden ser susceptibles de fer-se servir a varis llocs o que estan molt relacionades amb el … -
Using disqus comments and django-localeurl
Lately I have added comments to my company blog. We have it localized, so things turned out to be not so straight forward as one can think. django-localeurl This neat piece of code allows us to localize our URLs. You can find it in its bitbucket repository. So, in my blog I have four languages (english, catalan, spanish and french), each one with a different prefixed URL: http://example.com/blog/post_slug/ http://example.com/ca/blog/post_slug/ http://example.com/es/blog/post_slug/ http://example.com/fr/blog/post_slug/ Note that the english version doesn't have any prefix actually; this is a default from django-localeurl but you can change it if you want. disqus url So we want to include, of course, comments to our blog, and we are going to use disqus, a well-known service that makes our life more enjoyable without having to carry the burden of spam comments, implementing all the ubiquitous facebook, twitter, and many more logging services, to name a few. When using the universal JavaScript embed code, by default this script uses window.location to send the URL of the current page. As long as we are using localized URLs, if we don't modify this behavior then each localized URL would have its own comments. Hopefully, we can specify our URL with the … -
Django Cloud Browser
Ryan’s released a new version of his Cloud Browser application to PyPi. It supports S3 and Rackspace Cloud Files. Read his blog for the details. Tagged: Django -
Caktus Consulting Group Sponsors PyCon 2011
PyCon 2011 Atlanta is just around the corner, and I'm proud to announce that Caktus is a gold sponsor at the conference this year! We sponsored DjangoCon in both 2009 and 2010, and this year agreed to extend that support to the Python community in general.PyCon US is the annual gathering of software developers who ... -
Using Jinja2 To Generate LaTeX
I've generated PDF documents from webapps using XSL-FO with Apache FOP, HTML with XHTML2PDF, Python with ReportLab, SVG with Inkscape. But I still obtain the best results – in terms of robustness and typographic beauty – with LaTeX. However, writing LaTeX templates in Django's template language is hindered by syntax conflicts: both languages use '{}' and '%'. Since Django does not allow changes to its template syntax, I decided to use Jinja2 for a new project. After toying with several obscure escape sequences, I settled on a rather straightforward approach: latex_jinja_env = jinja2.Environment( block_start_string = '\BLOCK{', block_end_string = '}', variable_start_string = '\VAR{', variable_end_string = '}', comment_start_string = '\#{', comment_end_string = '}', line_statement_prefix = '%-', line_comment_prefix = '%#', trim_blocks = True, autoescape = False, ) … which plays nice with syntax highlighting: %- if graphicspath \graphicspath{{\VAR{graphicspath}}} %- endif \section{\VAR{obj.name|title}} \BLOCK{for item in items} \paragraph{\VAR{item.name|title}} \VAR{item.description} \BLOCK{endfor} \enjoy{!} -
Follow-Up to Weighted Sorting in Python
The activity on my latest blog post has been tremendous! I never expected that much activity within an hour or two of posting the article. The aim of this article is to provide an alternative solution to my weighted sort when you're after increased performance. It might just be useful to those who came here in search of a way to do weighted sorting in Python. I need to give a shout out to Jeremy Brown for suggesting this solution. He's so awesome :P While the example I posted in my previous article addressed my needs just fine, it is definitely not the fastest option. A better solution would be to completely remove the special IDs from the object list altogether and just place them in front of the list: import itertools import random object_ids = [random.randint(0, 100) for i in range(20)] special_ids = [random.choice(object_ids) for i in range(5)] not_special_ids = (i for i in object_ids if i not in special_ids) for i in itertools.chain(special_ids, not_special_ids): # do stuff with each ID pass This solution is quite different from my weighted sort, as there's no sorting going on at all, just a simple generator and using itertools to chain two … -
Simple Weighted Sort in Python
Last night I found myself in need of a simple weighted sort function in Python. I had a list of integers which represented object IDs in my project. Some of the objects needed to be processed before the others while iterating over the list of integers, and I already knew which object IDs those were. The order the rest of the object IDs were processed didn't matter at all. I just wanted the special object IDs to arrive at the beginning of the list, and the remaining object IDs could be in any order. I was surprised at how simple it was to produce such a weighted sort. Here's an example of what I did: import random object_ids = [random.randint(0, 100) for i in range(20)] special_ids = [random.choice(object_ids) for i in range(5)] print 'Object IDs:', object_ids print 'Special IDs:', special_ids object_ids.sort(key=special_ids.__contains__, reverse=True) print 'Object IDs:', object_ids And some sample output: Object IDs: [13, 97, 67, 5, 77, 58, 24, 99, 29, 20, 29, 75, 100, 31, 79, 5, 27, 11, 6, 1] Special IDs: [13, 1, 27, 6, 67] Object IDs: [13, 67, 27, 6, 1, 97, 5, 77, 58, 24, 99, 29, 20, 29, 75, 100, 31, 79, 5, … -
Building Cursors for the Disqus API
This last week we've been implementing cursors for the Disqus API (3.0). If you're not familiar, the concept is like cursors in your database: create a marker for where you are with your result set so you can iterate through a large set of results efficiently. Think of it like a snapshot. A marke... -
Building Cursors for the Disqus API
-
Cleaning Your Django Project With PyLint And Buildbot
There are a number of tools for checking whether your Python code meets a coding standard. These include pep8.py, PyChecker and PyLint. Of these, PyLint is the most comprehensive and is the tool which I prefer to use as part of my buildbot checks that run on every commit. PyLint works by parsing the Python [...] -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por admin
Você precisa repetir o processo de configuração do .htaccess para cada pasta. Mas não pode haver um .htaccess no public_html, apenas em subpastas. public_html/mysite/.htaccess public_html/mysite2/.htaccess O que dá para fazer é colocar um index.html com redirect para o projeto default dentro do public_html. Caso vc queria deixar um projeto de default. public_html/index.html Não sei se ficou claro :P -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Bruno Rodrigues
Excelente Tutorial!!!! O Melhor que eu achei! O suporte da uolhost é horrível. Como você faz pra utilizar subpastas? -
django-mediasync 2.1 for Django 1.3
Earlier today we released django-mediasync 2.1 in anticipation of Django's upcoming 1.3 release. The Django 1.3 RC was released last night so the final version should be coming any day now. This release changes the way static files are handled and breaks previous versions of mediasync. The old MEDIA_URL and MEDIA_ROOT settings are now meant to handle media uploaded by users while two new settings, STATIC_URL and STATIC_ROOT, handle static site content. Mediasync will first try to use STATIC_* settings and fall back to MEDIA_* if not found. This ensures that mediasync will work regardless of the version of Django being used. Find the package on PyPI and the source on GitHub. And as always, if you use mediasync please indicate it on Django Packages. -
django CMS 2.2 roadmap update
django CMS 2.2 roadmap update -
Help desk software?
I’m looking for some help-desk style software with some very specific features: Users create new help requests by emailing a support@example.com-style email. There should be some sort of concept of “support queues” with each queue having an associated email address. So there might be a “sales” queue by emailing sales@example.com, a client-specific queue at client-a@clients.example.com, etc. New issues (i.e. new emails) get automatically assigned to one of a pool of support staff. -
nashvegas 0.6 released
nashvegas 0.6 was released tonight to address a fairly critical bug. I ran into this bug tonight working on a project where I was making use of ContentTypes and realized that there were a bunch of expected ones missing. I quickly got the sinking feeling that this was a major bug in nashvegas so I set about to isolate and find the root cause so that I could fix it. I opened up the Django source code and took a look at what the syncdb command was doing as when I ran syncdb all the ContentType objects were created properly. I quickly noticed this code in the handle_noargs method: # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: try: import_module('.management', app_name) except ImportError, exc: # This is slightly hackish. We want to ignore ImportErrors # if the "management" module itself is missing -- but we don't # want to ignore the exception if the management module exists # but raises an ImportError for some reason. The only way we # can do this is to check the text of the exception. Note that # we're a bit broad in how we … -
nashvegas 0.6 released
nashvegas 0.6 was released tonight to address a fairly critical bug. I ran into this bug tonight working on a project where I was making use of ContentTypes and realized that there were a bunch of expected ones missing. I quickly got the sinking feeling that this was a major bug in nashvegas so I set about to isolate and find the root cause so that I could fix it. I opened up the Django source code and took a look at what the syncdb command was doing as when I ran syncdb all the ContentType objects were created properly. I quickly noticed this code in the handle_noargs method: # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: try: import_module('.management', app_name) except ImportError, exc: # This is slightly hackish. We want to ignore ImportErrors # if the "management" module itself is missing -- but we don't # want to ignore the exception if the management module exists # but raises an ImportError for some reason. The only way we # can do this is to check the text of the exception. Note that # we're a bit broad in how we … -
nashvegas 0.6 released
nashvegas 0.6 was released tonight to address a fairly critical bug. I ran into this bug tonight working on a project where I was making use of ContentTypes and realized that there were a bunch of expected ones missing. I quickly got the sinking feeling that this was a major bug in nashvegas so I set about to isolate and find the root cause so that I could fix it. I opened up the Django source code and took a look at what the syncdb command was doing as when I ran syncdb all the ContentType objects were created properly. I quickly noticed this code in the handle_noargs method: # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: try: import_module('.management', app_name) except ImportError, exc: # This is slightly hackish. We want to ignore ImportErrors # if the "management" module itself is missing -- but we don't # want to ignore the exception if the management module exists # but raises an ImportError for some reason. The only way we # can do this is to check the text of the exception. Note that # we're a bit broad in how we …