Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Собственные фильтры полей в админке Django
Пока Правильное Решение проблемы страдает в джанговском Trac'е уже два с половиной года от смены майнтейнеров и архитектурной астронавтики, мне как раз потребовалось это сегодня для Афиши. Оказывается, никого ждать не надо , и это вполне решаемо уже сейчас, хоть и с небольшим хаком процесса регистрации. Задача У нас есть моделька City, в которой страна задана целым числом — ID региона из яндексовой геобазы. Название в модели не хранится, а при необходимости вычисляется из ID запросом в геобазу: class City(models.Model): country_region_id = models.IntegerField() def country(self): return get_name_from_geobase(self.country_region_id) Если в админке сделать фильтр по полю country_region_id, получится некрасиво: Хочется заставить админку выводить не цифры, а то, что получается из country(). FilterSpec В админке за выдачу данных фильтров овечает несколько классов, определённых в django.contrib.admin.filterspecs. Каждый класс отвечает за то, чтобы из модели и типа поля вытащить данные для фильтра и определяет правила составления запроса. Стандартные FilterSpec'и умеют строить фильтры для полей разного типа: Для ForeignKey выбираются все данные из модели, на которую он ссылается. Для полей с choice'ами фильтрами являются сами choice'ы. Для BooleanField'ов предопределённый набор из двух значений: True и False. Для всех остальных полей делается distinct-выборка всех значений, которые есть в модели. Для того, чтобы выдавать названия стран, я и … -
Django 1.1 lançado
Django 1.1 lançado -
Django 1.1 lançado
Django 1.1 lançado -
Django 1.1
Por fin se ha anunciado la esperada versión 1.1 de Django. Ya se puede descargar desde el sitio oficial e incluye la actualización de seguirdad publicada ayer: Descarga Django 1.1 desde el sitio oficial. -
Django hits the big 1.1
Django 1.1 is out! This release has some great new features: aggregation support for SQL aggregate queries (COUNT, MIN, MAX) query expressions can now refer to another field in the query admin actions allow custom actions to be taken on a group of model objects in bulk a bunch of other stuff... RTFRN Many of our newer Django projects have been developed against the 1.1 feature set. django-blogdor supports admin actions for publishing posts. This has made the admin interface much easier to use for our bloggers. James is in the process of redeveloping this site, Sunlight Labs, against 1.1. Some of our other Django-powered sites include Sunlight Foundation, Earmark Watch, Capitol Words, and Read the Bill. We have been big proponents of Django here at Sunlight Labs. When organizations tell us that they are planning to use a CMS like Drupal, we urge them to consider using Django + Pinax instead. Pinax has many of the same features, but provides much more flexibility in the long run. We have also released many of our internal Django apps: django-blogdor blogging application django-gatekeeper generic model object moderation django-honeypot generic honeypot utilities to fight bot form submissions django-mediasync sync media with S3 … -
Django 1.1 Released
The Django project just announced that v1.1 is ready! Go here for the full release notes. Some notable changes include support for aggregate functions from within the ORM. This includes COUNT(), MAX(), MIN(), etc. Also, the concept of "unmanaged" models which allow you to easily support tables that pre-existed or were created by some other [...] Related posts:Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel) jQuery 1.4 Released Adventures in Django and Python – Part III -
Personal Site Sprint
The beginning of August, following my relocation to Charlotte, will kick off the Personal Site Sprint along with my friends Chris Harrison and Bryan Veloso. The sprint will end with a launch date of September 1st. What this means is we will all be redesigning and documenting the process of our personal site refresh. I will be detailing the process from initial pencil sketches all the way through to final launch. I might even throw in some screencasts. I am also going to take this opportunity to leave Movable Type in favor of Django. This is something I've wanted to do for a while and haven't had the time or energy to do. Personal projects are a PITA so I'm hoping that doing the sprint with two other great designers will keep me motivated. -
Django 1.0 Template Development: Sample Chapter “Serving Multiple Templates”
DISCLOSURE: I was sent this sample chapter by the publisher. I'm sure some of you folks will find it useful so I'm posting it. For a review of the book go here. Download Sample Chapter 6 "Serving Multiple Templates" Related posts:Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel) 8 Books To [...] Related posts:Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel) 8 Books To Get A Developer For The Holidays Django and Python First Impressions – Part II -
Serving multiple templates
-
Django 1.1
Django 1.1 is nearing a release and from what I can see about the new features the two most exciting one (to me at least) are improvements from the models end that is the "managed" model and the "proxy" models. Managed models would be good for existing tables that should not be managed by django. This is useful in some of my projects in which I am using django for database work but do not necessarily need django to manage it. Now if only the database evolve stuff or database versioning stuff: http://paltman.com/2008/jul/03/managing-database-changes-in-django/ could be integrated into the core, now that would be superb!Talking about migration too, is this project: http://code.google.com/p/dmigrate/ still alive. Doesn't look like there are any downloadable stuff. The examples are half of what I need what I further need is the ability to undo db migration changes between revisions. -
django-renderformplain
django-renderformplain is a Django app that allows you to render forms in plain text. I have found myself implementing quite a bit of styling into my forms and thought why do it once more when I want to render just the data. Renderformplain works both with bound forms (renders bound data) and unbound forms (renders [...] -
The lack of magic in Django
...or why Rails and Zope 2 were too magical. -
Summer Spam
Spam is occupying more than its customary share of my attention in recent weeks. I've long had a morbid fascination with sleazy human communication (hence Purportal.com). That makes the always-relentless stream of spam, though not exactly welcome, at least interesting. Spam volume also seems to have increased during this period. The number of spam attempts my mail server rejects per day had been steady at around 3,000 for months. Now it's back up around 5,000 or 6,000. I run my own mail server and fight spam via greylisting, blacklisting, and other strict technical rules. This setup rejects 99+% of the spam aimed at the domains I host, but some still gets through to me. Never enough to displace real mail, but enough to keep my little hobby-interest alive. Here are some of the spam highlights of my summer so far: After one too many identical HTML spams, I took the rare step of adding a custom rule to my mail server config. I started rejecting all mail with "Content-Type: text/html; charset=us-ascii". In this age of Unicode, that's turned out to be a pretty safe bet. Lots of rejections and no known false positives. I received a weird email about money … -
On "magic", once again
So it seems Giles Bowkett is upset about use of the word “magic”. I’m happy to agree with the general consensus from various fora that the specific article he’s complaining about is, well, pretty much content-free. I could read that post over and over and still have no idea what actual things the author liked about Django or didn’t like about Rails. But I’ve pretty much learned to ignore content-free hype, and that’s what I ... Read full entry -
On "magic", once again
So it seems Giles Bowkett is upset about use of the word “magic”. I’m happy to agree with the general consensus from various fora that the specific article he’s complaining about is, well, pretty much content-free. I could read that post over and over and still have no idea what actual things the author liked about Django or didn’t like about Rails. But I’ve pretty much learned to ignore content-free hype ... Read full entry and comments -
Django 1.1 Release Candidate ya está aquí
Se ha anunciado la disponibilidad de Django 1.1 Release Candidate en el weblog oficial de Django. Django 1.1 RC no está pensado para uso en producción pero es un paso más hacia la versión final de Django 1.1: Incluye casi todas las mejoras que estarán presentes en la versión final. Se puede descargar directamente desde aquí. La versión final de Django 1.1 se espera para la semana que viene. -
Anúncio oficial da PythonBrasil[5]
Anúncio oficial da PythonBrasil[5] -
Anúncio oficial da PythonBrasil[5]
Anúncio oficial da PythonBrasil[5] -
Django Forms Quick Reference
Django's forms have fields like models, but you access them in a completely different way. I've found it hard to remember the correct way to access form field data properly, so this is a summary of the things I need to do with forms and how to do them. In particular these are useful in the form's __init__ method after calling super() to set up the form the way you want to. -
Forms, forms, forms
Some questions answered about Django forms. -
oEmbed y Django: incrusta contenidos de servicios web con django-oembed
oEmbed es un formato que permite usar una representación embebida de una URL en sitios web de terceros. La API de oEmbed permite a un sitio web incrustar contenido (como fotos o vídeos) de otros servicios web simplemente con un enlace al recurso que quiere se publicar. De esta forma se evita tener que utilizar una API distinta para incrustar contenidos de cada servicio web. Varios sitios como Flickr, Viddler, Qik, Hulu o Vimeo permiten acceder a sus contenidos mediante oEmbed. Además el sitio web oohEmbed sirve como wrapper para acceder a contenidos de otros sitios como YouTube, Wikipedia ó Wordpress.com entre otros ... -
Improved Django FormWizard
A few months back I had a project that I thought needed a wizard-style interface for one of its forms. For a while now Django has included the FormWizard class in django.contrib.formtools.wizard so I decided to use that. However, I immediately hit a couple of issues with it.FormWizard requires you to output the previous_fields context variable in each of the form's step templates. Django's -
ETag magic with Django
An ETag is a feature of HTTP that allows for a web server to know if content has changed since the last time the browser visited the page. The client sends the ETag from the cached page in a header. If the ETag in the header matches the current ETag then the server lets the browser know that the cached is up-to-date by sending back a 304 Not Modified response. -
ETag magic with Django
An ETag is a feature of HTTP that allows for a web server to know if content has changed since the last time the browser visited the page. The client sends the ETag from the cached page in a header. If the ETag in the header matches the current ETag then the server lets the browser know that the cached is up-to-date by sending back a 304 Not Modified response. The most natural way to build an ETag is to generate it from the HTML returned by the view, which I believe is how the default view caching works in Django. The downside of this is that the page is generated even if the client has a cached copy, and all that is saved is the cost of sending the page to the client. Bigger wins can be had by using Django's conditional view processing to calculate an ETag outside of the view. I haven't seen the requirements documented, but as far as I can tell there is only a single property needed in an ETag: The ETag should vary with the page, i.e. when the page content changes, the ETag chages. A simple alternative to generating an ETag from … -
ETag magic with Django
An ETag is a feature of HTTP that allows for a web server to know if content has changed since the last time the browser visited the page. The client sends the ETag from the cached page in a header. If the ETag in the header matches the current ETag then the server lets the browser know that the cached is up-to-date by sending back a 304 Not Modified response. The most natural way to build an ETag is to generate it from the HTML returned by the view, which I believe is how the default view caching works in Django. The downside of this is that the page is generated even if the client has a cached copy, and all that is saved is the cost of sending the page to the client. Bigger wins can be had by using Django's conditional view processing to calculate an ETag outside of the view. I haven't seen the requirements documented, but as far as I can tell there is only a single property needed in an ETag: The ETag should vary with the page, i.e. when the page content changes, the ETag chages. A simple alternative to generating an ETag from …