Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Announcement: Dates for Django Training, London
After delivering some successful django training for Bangor University in January, I’ve finally got around to setting up my own course. This will be a 2 day introduction to Django for programmers, and will take place on the 17th and 18th May 2011 at City University, London. The course assumes that you can already program [...] -
Django Pattern For Model Permissions
I think I've found an interesting way to set up a permissions system in Django. This system allows you to specify granular permissions on specific object instances and is template friendly. Setup The Permissions InfrastructureFirst, you create an "abstract" Permissions class that models will use as a permissions base class. This base permissions class sets up simple caching for the permissions and creates some common methods to be used by all permissions objects. The current_user represents the logged in that you want to check permissions for a particular object.Notice the use of threadlocals here. If current_user is not supplied in the constructor, the class will try to lookup the current_user from a variable by the threadlocals middleware (see below). Be warned, however, some people don't seem to like the threadlocals approach. To be honest, I'm still trying to evaluate the pluses and minuses, but it sure makes certain things in the templates easier. Comments are welcome. core/permissions.pyfrom core.middleware import threadlocals class Permissions(object): def __init__(self, obj, current_user=False): if not current_user: current_user=threadlocals.get_current_user() if not current_user: current_user = None self.current_user = current_user self.obj = obj self.cache = {} def clear_cache(self, key=None): if key: try: del self.cache[key] except KeyError: pass else: self.cache.clear() def get_current_user(self): … -
Satchmo Status Update
Despite the lack of activity on the satchmo site, there is still plenty of work going on to make Satchmo more stable, feature rich and generally all around better. -
DjangoAstuce : masquer certains champs des settings dans la vue de Debug
Par défaut, la vue de DEBUG affiche toutes les settings. Heureusement pour nous, gentils petits djangonautes, les password des BD mais aussi le password du user emails sont remplacés par des belles petites ***.   Mais comment faire pour masquer d'autre champs ? Comme des champs de KEY d'API ou de password divers ? Parce qu'après ... -
Internet Explorer, jQuery, AJAX and HTML5…
… or how “invalid” HTML can break your JavaScript without a trace The problem: A few days ago I had the following case. A script that I wrote was working everywhere except in the Internet Explorer(IE) 8 and 7. To be honest I don`t remember the exact error message but when I use the built-in [...] -
Comentário sobre configurando um projeto django no uol host – terceira parte por Valder
Thiago, blz ? Mas, no caso o que vc está fazendo errado é que o .htaccess deve ficar sempre uma pasta abaixo do projeto Django ('settings.py') Assim vc vai apontar o PYTHONPATH para uma pasta abaixo do projeto, no local onde está o .htaccess. Ai ele aceita ter vários projetos de django na mesma hospedagem. Sendo assim o domínio do seu cliente iria para www.valdergallo.com.br/thiago/ onde teriamos os seguintes diretórios: public_html thiago .htaccess site_django settings.py myapp media_django Lembrando que quem vai servir os seus arquivos estáticos é o próprio django. Então o caminho dos mesmos deve ser definido no settings.py Já tinha respondido isso em outro post. Porém acho que ficou meio vago. Espero que assim fique melhor. Abraço -
Django Authentication using an Email Address
A custom authentication backend which allows a user to login using their email address in Django. -
Issues using django-compress and django.contrib.staticfiles from django 1.3
There is no way to use both django-compress and django.contrib.staticilfes from new django 1.3. MEDIA_URL and MEDIA_ROOT hardcoded into django-compress utility functions so here ismy fork of django-compress on github with fix.I've added two new settings COMPRESS_URL and COMPRESS_ROOT which points by default to MEDIA_URL and MEDIA_ROOT respectively for backward compatibility.django-compress is extremely useful tool which provide possibility to organize your JavaScript and CSS files around your project. Also there is a couple of useful features like support of YUI compressor and building of bunch of JavaScript or CSS files into one.Read more about django-compress -
direct_to_template generic view class-based replacement for django 1.3
I was in love with direct_to_template shortcut from django.views.generic.simpleUpdate: It was my lack of attention to the docs. new render shortcut do the same thing as code belowIt's extremely useful to use direct_to_template instead of render_to_response because there is no necessary to put RequestContext to direct_to_template shourcut. But now it's deprecated so I decided to replace it with small class-based view which do same thing as old direct_to_template but – without restriction of new TemplateView where is no way to put extra context.from django.views.generic.base import TemplateResponseMixinfrom django.template import RequestContextclass RenderTemplate(TemplateResponseMixin): """django 1.3+ Class-Based replacement for django.views.generic.simple.direct_to_template Usage: context = {} return RenderTemplate.view(context, \ request=request, template_name="main.html") """ @classmethod def view(cls, context, render_args={}, **initkwargs): obj = cls() for key, val in initkwargs.iteritems(): setattr(obj, key, val) return obj.render_to_response(context, **render_args) def render_to_response(self, context, **kwargs): return super(RenderTemplate, self)\ .render_to_response(RequestContext(self.request, \ context), **kwargs) -
Upgrading to Django 1.3?
Should you upgrade to Django 1.3? Upgrade any web framework in your application in general? Try this decision chart here http://www.djangopro.com/2011/03/should-i-upgrade-to-django-1-3/: -
Deploying to ep.io with secret stuff
hej -
Deploying to ep.io with secret stuff
hej -
Django Dynamically Generated Images with Cairo
It is fairly simple to dynamically generate images in your Django views using the Cairo 2D graphics library. -
2009 Django Dash Complete
The 2009 Django Dash is done. The site (http://alt.djangodash.com/) has the full commit logs and some interesting stats (overall, per team, per dasher). I'll do a better post-mortem tomorrow. Congratulations to all who participated and hope to see you next year! -
Postmortem: Django Dash 2009
Now that the Dash is over, I wanted to write up a little postmortem with some thoughts about how things went. To understate things, this year's Django Dash was amazing. In virtually every regard, the competition exceeded last year's contest. What Went Well First, a huge thanks to the sponsors. We went from 8 last year to 12 this year. Without them, there would be no prizes for the contest. We also doubled the number of teams that actively competed, which really impressed me. Many of the entries seem much more complete than last year as well. Using IRC & Twitter were also big wins. The IRC channel (#django-dash on Freenode) was where the party was most of the weekend (thanks to Eric for setting it up and admin'ing it). And being able to more easily/effectively distribute information via Twitter was nice (less infrastructure/headaches for me). Plus it was fun watching the #djangodash fly by. More stats and sparklines improved the website itself. I used the jquery.sparkline library and the new Aggregation support in Django trunk (soon 1.1), both of which proved easy to use and made it a little easier to spectate the contest. Bumping the team size from … -
Haystack 1.0.0-rc1
Haystack 1.0.0-rc1 -
Haystack 1.0 Final Released
Haystack 1.0 Final Released -
Better Local Settings
Better Local Settings -
Comentário sobre configurando um projeto django no uol host – terceira parte por thiago
Olá, Estou tentando colocar no servidor da uolhost um projeto em django. no site da uol indica criar o projeto dentro da pasta publica, fiquei com receio de fazer dessa maneira. A hospedagem é uma revenda, ou seja no mesmo ftp tem outras pastas de outros sistemas, no caso desse projeto ficou "sitedjango.com" e dentro do ftp existe uma pasta exclusiva para esse site home\usuario\sitedjango coloquei nessa pasta o projeto, e na pasta home\usuario\sitedjango\public_html coloquei a pasta media. Dentro da pasta home\usuario\sitedjango inclui o arquivo .htaccess com a configuração PythonPath "['/home/drdg/Django-1.3', '/home/usuario/sitedjango'] + sys.path". O problema é que o apache não esta aceitando a configuração quando entro no site do projeto aparece a msg "Verifique se algum dos arquivos index.html ou index.php existem no diretório /public_html", já viu esse erro antes? -
Authorize.Net Credit Card Form in Django
This Django form will submit credit card data to a payment gateway such as Authorize.Net when the form is validated. If the payment is not accepted then the error response from the payment gateway is added to the form's non field errors as shown in the image to the left. This is a follow to yesterday's post, Accept Credit Cards in Django with Authorize.Net, in which I introduced a very simple example using the quix.pay Python module to process credit cards in a Django project. This moves the payment gateway request into the Form object rather than the view. It also moves some of those configurations into your typical Django settings. At some point in the future a finalized version of this technique may be packaged and released by Quixotix Software (open-source of course) but in the mean time I thought I would share you how you might implement this on your own. The nice thing about this approach is that the view becomes much more simple and failures from the payment gateway are added to the forms' errors. So let's look at what the view looks like first. View from django.template import RequestContext from django.shortcuts import render_to_response from django.http … -
A lightweight task queue for Django
It's quite common when building out a website to trigger actions during the normal request/response cycle that may be time-consuming. Examples of these actions might be: sending email, for example a contact form checking a comment for spam by sending to Akismet thumbnailing an image I remember last year about this time my coworkers and I got pretty excited about Celery, a distributed task queue, that provided a really nice API for executing tasks out-of-process. Basically just decorate functions with the @task decorator and so long as everything is configured properly, they will execute out of process. Celery is an actively-developed project with great documentation and an incredibly rich feature-set, but all those features come with the added cost of lots of configuration and the need for integration with a number of projects (celery, django-celery, kombu, django-kombu, pyparsing, mailer). I needed a lightweight task queue for some side-projects and rather than trying to integrate all the various celery dependencies (and pinning all the correct versions) I did what anyone would do: rolled my own. -
Caktus 2011 Summer Internship Program
I'm excited to announce that Caktus is launching its summer internship program. It is a 12 week paid position in our Carrboro, NC office. We're in driving distance from UNC Chapel Hill, NC State in Raleigh, and Duke in Durham, so students from all parts of the NC Research Triangle are welcome to apply.We are ... -
Caktus 2011 Summer Internship Program
I'm excited to announce that Caktus is launching its summer internship program. It is a 12 week paid position in our Carrboro, NC office. We're in driving distance from UNC Chapel Hill, NC State in Raleigh, and Duke in Durham, so students from all parts of the NC Research Triangle are welcome to apply. -
Blog Posts Via Email With CloudMailin.com
I recently learned (with horror) that a co-worker wrote her blog posts in Gmail, copied the rich text to WordPress, then copy and pasted the generated HTML into our Markdown-enabled blog backend. To be fair, our nerdy authoring tool is a bit much for non-technical users and doesn't really fit into most "normal" workflows. Additionally, she emails her posts to an internal list so Gmail was a natural authoring tool. There had to be some common ground we could find; blog posts still written in Markdown while allowing her to use Gmail to write her posts. Our solution was to enable post-by-email on the blog. By adding a special email address to the recipients, the message is parsed into Markdown, a draft post is created, and she receives an email reply a few seconds later with a link to edit the new post. From there she can review and publish it in a few clicks resulting in a much improved workflow. We wanted the draft posts created immediately and I didn't care to be polling a mail server every few seconds. Fortunately, we found a new service that made this project incredibly easy to implement. CloudMailin.com CloudMailin.com is a fantastic … -
Accept Credit Cards in Django with Authorize.Net
Accepting credit cards in your Django applications using the Authorize.Net payment gateway is easier than you might think. Using the quix.pay Python module to do the heavy lifting with Authorize.Net, all you need to get started is a simple Django form. You will need to either download quix.pay and install it using the setup.py script or download and install quix.pay using the easy_install command: easy_install quix.pay The quix.pay Python module provides credit card processing using online payment gateways including Authorize.Net. For those who are interested, I wrote up a more detailed look at quix.pay here: Authorize.NET Payment Gateway in Python You should also have the "API Login ID" and "Transaction Key" for your Authorize.Net merchant account or developer account. This would have been provided to you by Authorize.Net when you signed up. The Django code below shows a very simple credit card form. Along with the amount to charge the credit card, this is the minimum data you need to pass along to Authorize.Net (depending on your account security settings). from django import forms class PaymentForm(forms.Form): first_name = forms.CharField(max_length=50) last_name = forms.CharField(max_length=50) card_number = forms.CharField(max_length=16) expiration_month = forms.CharField(max_length=2) expiration_year = forms.CharField(max_length=4) security_code = forms.CharField(max_length=4) This next snippet of Django code …