Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Initial DB data
Within your application on the same level as your models place a folder named “fixtures” In my current setup that means “app/models/fixtures/”, but in a normal setup that would be “app/fixtures/” Within that file all you need to do is add a file with the extension “xml” or “json”. The syntax looks a lot nicer for “json”: [ { "model": "app_name.model_name", "pk": 1, "fields": { "name": "A", "value": 5 } }, { "model": "app_name.model_name", "pk": 3, "fields": { "name": "C", "value": 15 } } ] When you’re all set with your data all you need to do is run “python manage.py loaddata json_filename” (leaving off the “json” extension) -
Liberada a versão do Django candidata à 1.0!
Saiu a versão candidata à 1.0 do Django! Agora acredito que só serão aceitos correções de defeitos, atualizações de tradução e documentação. Existe ainda um ticket (#8796) da django-l10n-portuguese, no roadmap da 1.0, para a atualização do arquivo POT de localização. Falta apenas 10 strings a serem traduzidas, revisões e uma tarefa sugerida pelo Luciano Ramalho que pode ser encontrada na discussão http://groups.google.com/group/django-l10n-portuguese/browse_thread/thread/8c1c0460d19ccc27. Quem se interessar, envie suas sugestões para a lista de localização ou fique à vontade em anexar seus patchs no ticket #8796. Confira também as notas de lançamento da versão candidata à 1.0. Note que ela ainda não é a versão definitiva e não é recomendada para o uso em produção, porém creio que não haverá nenhum incidente que atrasará seu lançamento. -
E-commerce y django
Pues he estado revisando mi correo, particularmente la etiqueta de django-es, y alguna persona preguntaba por como hacer comercio electrónico con django, y le recomendaron la pagina http://www.satchmoproject.com/ esta el código con licencia bsd y algunos ejemplos de paginas donde la usan, e increíblemente (solo para mi) lo usan en la tienda de la Free Software Foundation en http://shop.fsf.org/, en mi incredulidad debia comprobarlo y lo primero que se me ocurrió fue ir a http://shop.fsf.org/admin y efectivamente allí estaba, la interfaz administrativa de django. -
Django 1.0 Release Imminent
If all goes well today then Django 1.0 should be with us soon! This is an exciting time for the fantastic framework. I look forward to seeing code stability and allowing myself to stop running from the latest SVN dev version! Well done to everybody involved! :) I'm also happy to hear that the Django team is throwing me a party on my birthday the 6th of September! It's a shame I can't go, but anybody closer to Silicon Valley should go along. edit Django 1.0, It's in the wild! -
Palestra Django na Impacta
Participei hoje do SP Python Day, evento organizado pelo Fórum Impacta de Tecnologia da Informação, realizado nas dependências da Faculdade Impacta. A galera participou em peso, lotando 3 auditórios da faculdade (um principal com os palestrantes e outros dois com transmissão simultânea). Foi muito bom reencontrar os amigos e ver o grande interesse do público [...] -
Django Group in Nashville
I was pretty pumped to get the invite from Trey Piepmeier tonight about trying to start a local (Nashville, TN) Django meetup/group. If you are in the area, head on over and sign up! -
Django Group in Nashville
I was pretty pumped to get the invite from Trey Piepmeier tonight about trying to start a local (Nashville, TN) Django meetup/group. If you are in the area, head on over and sign up! -
Portuguese translation of Django 1.0
I've just submitted a patch for the Portuguese translation. If you are a Django user and know Portuguese, please take a look to the translation strings and submit any fix before the final 1.0 release. Meanwhile, you can download the unofficial version in the downloads section. Update: The patch is already in SVN. -
Portuguese translation of Django 1.0
I've just submitted a patch for the Portuguese translation. If you are a Django user and know Portuguese, please take a look to the translation strings and submit any fix before the final 1.0 release. Meanwhile, you can download the unofficial version in the downloads section. Update: The patch is already in SVN. -
Postback: Why I choose AGPLv3 for my code
It's been a few days since I posted my decision to release all my code related to Django under the AGPLv3 license. It generated quite a few reactions I didn't expect, so let me tell you the full story. It all started when I needed to support, let's call it technology X - which is pretty hot right now -, in byNotes. I first searched if someone had done it and I found there was a generic and abstract Python implementation, but it needed a lot of work to be adapted to Django. So I decided to build my own solution from scratch. The same day I released the first version, I found an announcement posted the previous day from another developer who had also coded technology X support for Django. It's a pity when that happens, since one of us could have spent that time implementing technology Y. However, it's difficult to avoid those situations, so we must live with it. The bad thing (TM) happened a few days later, when I was chatting with a friend on freenode. I told him I've written support for technology X and it could be useful for a project he's working on. … -
Wapi 0.2 released
I've just finished preparing the Wapi code for the 0.2 release, so you can now download it. oauthsp will be ready in a few days (probably this weekend). -
Code bloat in your Django projects: Models
My current project’s getting a bit large, so I figured I should start subdividing the code a bit. The project’s already split up into multiple applications, but my main application is growing… The first thing I’ve done is split up my models.py into multiple files and moved them into a folder named models. Folder structure is: project/application/models/model_file.py All that’s left to be done is to add an _init_.py to that folder and import all your models within the __init__.py. You’ll also need to make sure the app_label set on each of your models. For example: class Shape(models.Model): value = models.CharField () class Meta: app_label = "my_project" This may turn into a series…lets see if there’s anything else that needs better organization. -
Django testing for absolute beginners
I want to interrupt my series of posts on Practical Django Projects and quickly show how to setup the most basic of tests, and hopefully convince you why taking some small steps and starting with one line of test code can save your sanity especially if you're tracking a code breaking trunk. First the why.. In my previous post I wrote about getting an error in the browser: ImproperlyConfigured -
URLsafe base64 encoding/decoding in two lines
Simon has recently featured this snippet which shrinks a SHA1 hash from 40 to 27 characters using base65 encoding. I've been using another approach for some time and, modestly, I think mine is better, so let me tell you how I do it before you start using the suboptimal approach. Python does it for us First, the base64 module already provides a pair of functions, aptly named urlsafe_b64encode and urlsafe_b64decode, which do quasi-safe url encoding using base64. For example: >>> base64.urlsafe_b64encode(sha1('foobar').digest()) 'iEPX-SQWIR3p67lj_0zigSWTKHg=' The problem here is the equal sign, since we can't put it safely in a URL. However, since we are using this to store a hash and we're going to generate the hash again when we verify the data, we can encode the hash again instead of decoding the base64-encoded string, which lets us safely remove the equal sign. Furthermore, we are also using 27 characters, the same as the other more complex implementation. Can we decode it? Sure! Sometimes, you'll want to decode the base64 encoded data. However, once we remove the equal sign, we can't no longer pass the base64 encoded string to urlsafe_b64decode: >>> base64.urlsafe_b64decode('iEPX-SQWIR3p67lj_0zigSWTKHg') Traceback (most recent call last): File "<stdin>", line 1, in … -
A PHP developer looks into Django
Thierry Schellenbach has published a very interesting article about his study for selecting a Web framework. A PHP developer that values the Symfony framework, after weighing the issue along with a colleague he decided that for many projects Django and Python are a better fit than Symfony and PHP. This is not a typical holy [...] -
AGPLv3 explained
I think there are lots of people which misunterstand the Affero GPL v3, so I decided to write this entry to clarify some things. Keep in mind I'm not a lawyer, so you should read my advice with a grain of salt. I've been using free software licenses for some years and I always take the time to read and understand them, but that doesn't mean I cannot make mistakes or misunderstand some sections. You can Sell commercial software under an AGPLv3 license: Nobody prevents you from selling AGPLv3 licensed code, even when you didn't write it. However, customers buying the software from you must abide by the license terms. Paying for an AGPLv3 product doesn't mean you can avoid the license terms. However, if you're the copyright owner, you can sell the same software under a different license. Build another software on top of it: AGPLv3 grants you permission to download and modify any software which you can use, even if it's over a network (this an important difference with the GPLv3). You're free to modify it or use it into another project, making your project a derivative work of the original software. Link to or use BSD … -
Building a website API with Django. Part 6: Documentation
This entry puts and end to "Building a website API with Django". I think I've covered everything you need to build a website API with Wapi, so it's now time for you to start playing with it. I hope you've enjoyed reading this series as much as I enjoyed writing it. I've finally pylinted and documented almost all the code, so Wapi 0.2 should be released in the next few hours. From now, I'll try to keep the current API and every backwards incompatible change will be documented. Documenting your API with Wapi Documenting your functions As we've seen on part 4 on this series, every API parameter takes an optional third argument which documents it. In addition, every function docstring is also passed to the documentation template. Furthermore, validators applied to parameters are also autodocumented. Let's see an example: @readonly @required_parameter('type', int, _('Admin division type, ranging from 1 to 4.'), validators=RangeValidator(min_value=1, max_value=4)) @required_parameter('id', int, _('The administrative division id.')) def geo__admin(self, request, dct): """Returns information for the given administrative division type and id. Keep in mind that administrative divisions identificators are not guaranteed to be permanent, as it happens with geoname identifiers.""" If you want to check how it looks … -
Django vs Symfony
As you can see from the posts (one, two) I’ve always been a big Symfony fan. Symfony is really great, but my current favourite is clearly Django. I had to dive deep into python to use it, but it was well worth the effort. Choosing Django: Django has a few killer features which make it a better [...] -
3. Customizing the Simple CMS
This is part 3 of a series of posts on James Bennett's excellent Practical Django Projects. The table of contents and explanation can be found here. Improving the Search Function with Keywords On page 34 when defining your first model class, remove the Admin class to replace it with new a separate newforms admin file (hereafter just admin). If I've ignored code that works just fine I just use -
Aplicação comments do Django refatorada
Boa notícia para os desenvolvedores Django! Ontem foi feita a refatoração da aplicação bult-in comments do Django (changeset 8557). Dentre as mudanças, as que mais gostei são: Aquela idéia de FreeComment foi abandonada: agora existe somente um model Comment; foram adicionados os campos email e URL; e agora é documentado! Detalhes de como atualizar seu código para o novo comments em http://docs.djangoproject.com/en/dev/ref/contrib/comments/upgrade/. Se ainda não gosta desta aplicação, existe uma alternativa com suporte a threads: é o django-threadedcomments. -
New App: Django and AWS
I have started a new app over on github called django-aws. It's pretty bare bones right now but wanted to announce it earlier rather than later as I am hoping to: Get some folks who might be interested to help me out. Get some eyeballs on it for recommendations for how to (or how to not) do certain things. I would appreciate any feedback or help that I might be able to scrounge up! This app will have a strict dependency on boto which is a really cool project provides the de facto way for interacting with Amazon Web Services in the Python language. -
New App: Django and AWS
I have started a new app over on github called django-aws. It's pretty bare bones right now but wanted to announce it earlier rather than later as I am hoping to: Get some folks who might be interested to help me out. Get some eyeballs on it for recommendations for how to (or how to not) do certain things. I would appreciate any feedback or help that I might be able to scrounge up! This app will have a strict dependency on boto which is a really cool project provides the de facto way for interacting with Amazon Web Services in the Python language. -
1. Welcome to Django
This is part 1 of a series of posts on James Bennett's excellent Practical Django Projects. The main post can be found here. This is not a critique of James's book, but rather a collection of notes and code revisions to accompany it, both updating it for Django 1.x and things beginners may want to consider. The headings follow the subheadings in the book. Say Hello to Python If you haven't -
Dynamic upload paths in Django
For a while I’ve been using the CustomImageField as a way to specify an upload path for images. It’s a hack that lets you use ids or slugs from your models in the upload path, e.g.: /path/to/media/photos/1234/flowers.jpg or /path/to/media/photos/scotland-trip/castle.jpg CustomImageField no more Since the FileStorageRefactor was merged in to trunk r8244, it’s no longer necessary to use the custom field. Other recent changes to trunk mean that it doesn’t work any more in its current state, so this is a good time to retire it. Pass a callable in upload_to It is now possible for the upload_to parameter of the FileField or ImageField to be a callable, instead of a string. The callable is passed the current model instance and uploaded file name and must return a path. That sounds ideal. Here’s an example: import os from django.db import models def get_image_path(instance, filename): return os.path.join('photos', str(instance.id), filename) class Photo(models.Model): image = models.ImageField(upload_to=get_image_path) get_image_path is the callable (in this case a function). It simply gets the id from the instance of Photo and uses that in the upload path. Images will be uploaded to paths like: photos/1/kitty.jpg You can use whatever fields are in the instance (slugs, etc), or fields in … -
Django and mod_wsgi: A perfect match!
mod_wsgi is an Apache module for serving WSGI-based Python web applications from the Apache HTTP server. Django, along with almost every other Python web framework today, comes bundled with a backend for acting like a WSGI application. A couple of months ago I decided to try it out in spite of mod_python. Discovering and trying out mod_wsgi really suprised me. It can take a massive beating, and outperforms mod_python in every practical aspect. The setup You will need a short Python "bootstrap" script to create a WSGI-handler for your Django project. Here is an example (call it wsgi_handler.py and place it in the root directory of your Django project - the one with manage.py and settings.py): import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..') os.environ['DJANGO_SETTINGS_MODULE'] = 'projectname.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() Finally set up your Apache virtualhost to use mod_wsgi: <VirtualHost *> ServerName www.projectname.org ServerAlias *projectname.org Alias /admin_media /usr/lib/python2.4/site-packages/django/contrib/admin/media <Location /admin_media> Order allow,deny Allow from all </Location> Alias /media /home/user/projectname/media <Location /media> Order allow,deny Allow from all </Location> WSGIScriptAlias / /home/user/projectname/wsgi_handler.py WSGIDaemonProcess projectname user=user group=user processes=1 threads=10 WSGIProcessGroup projectname </VirtualHost> In the WSGIDaemonProcess line, you can easily manage the amount of system resources (measured in processes and threads) mod_wsgi should …