Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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, ... -
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, NC office (a short drive from Raleigh, Durham, and Chapel Hill). -
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 ... -
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. -
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 … -
Creating a Custom Panel for the Django Debug Toolbar
Sometimes you work on stuff you don’t really control, eg. when interacting with some mysterious SOAP server accross the Internets, and you’d appreciate a little help from the Django ecosystem to ease debugging. That’s — you guessed it — my case currently, and I really appreciated being able to create my own custom panel for adding specific debugging capabilities to the awesome Django Debug Toolbar. Here’s how I did, learning mainly from the code of the panels shipping with the DJT. I’m supposing you have installed and configured the DJT in your project already. First of all, create a panels.py module within one of your app (or wherever you want as it’s in your python path) and create a DebugPanel derivated class, like this: from debug_toolbar.panels import DebugPanel from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ class MyUsefulDebugPanel(DebugPanel): name = 'MyUseful' has_content = True def nav_title(self): return _('Useful Infos') def title(self): return _('My Useful Debug Panel') def url(self): return '' def content(self): context = self.context.copy() context.update({ 'infos': [ {'plop': 'plip'}, {'plop': 'plup'}, ], }) return render_to_string('panels/my_useful_panel.html', context) The debug panel class methods and code should be self-explanatory enough. Just note you have to create a template, here panels/my_useful_panel.html … -
Disqus experience - cache of model's related fields
Very interesting tricks from Disqus: Scaling The World’s Largest Django ApplicationThe main idea to retrieve related fields by two requests instead of 1 + 25 sql requests using post.userSuch situation caused in several projects simultaneously so I working on optimization things right now.# cacheposts = Post.objects.all()[0:25]users = dict( (u.pk, u) for u in \ User.objects.filter(pk__in=set(p.user_id for p in posts)))for p in posts: p.__user_cache = users.get(p.user_id)And don't forget about SQL indexes - in all cases when field used in ORDER or WHERE sql statements it will increase performance a lot -
django-meio-easytags 0.4 released!
I just released the version 0.4 of the django-meio-easytags. I added a subclass of django’s default template tags Library. And now it’s easier to create a template tag. Take a look. Projects page Read the Docs Download from Github -
Basic Python Logging in Django 1.2: Debugging Made Simple
When I was deploying my new social shopping site Wantbox a couple of month ago, I discovered that I couldn’t use the Django print command in my live Dreamhost (Passenger WSGI) environment like this: print "Hello world!" As a new site, I was still debugging a few persistent nits and really needed to print out messages when certain areas of the code were accessed. A few sites recommended that I try the Django debug toolbar, but I was having trouble getting that to work reliably in my Dreamhost setup. I searched around a bit more and after consuming many web pages, finally discovered a dead simple solution using the built-in Python logging module. Python Logging in Django, Step-by-Step: Open your “settings.py” file and add this code to the bottom: # setup logger import logging PROJECT_DIR = os.path.dirname(__file__) PARENT_DIR = os.path.dirname(PROJECT_DIR) logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', filename=os.path.join(PARENT_DIR, 'django.log'), filemode='a+')</pre> Create a file called “django.log” at the same level as your project, my setup looks like: . .. .htaccess django.log passenger_wsgi.py passenger_wsgi.pyc public tmp wantbox (my django project) In the view where you need to “print” add the following: import logging logging.debug("hello world!") logging.info("this is some interesting info!") logging.error("this is an error!") Now …