Recently, in my work(at Machinalis: www.machinalis.com) I had the tough experience of having to upgrade a Django app built with Django 0.96 to Django 1.2.4.
I had to deal with things like oldforms, newforms, ObjectPaginator, changing 'maxlength' to 'max_length' in models fieleds and a long list of etc's.
But it came the time for me to deal with integrating csrf to all the giant bunch of forms there around... And that's not meant to be done by a human being :-P
So, I created a Python script for that. You can get it from my GiHub here.
Appart from that, you'll need to add this 'django.middleware.csrf.CsrfViewMiddleware' to MIDDLEWARE_CLASSES in settings.py and, depending on the nature of your project, making several changes more. I'd suggest taking a look(as I did) at the Django Project Reference on CSRF here.
More scripts I made to help upgrading Django 0.96 to 1.2.4 coming soon!
Colección de recortes y cosas útiles, simpáticas, interesantes(o las 3!) de Matías Herranz.
Mostrando entradas con la etiqueta templates. Mostrar todas las entradas
Mostrando entradas con la etiqueta templates. Mostrar todas las entradas
1 de febrero de 2011
24 de septiembre de 2009
Iterating over a dictionary in Django templates
Just a quick one: To iterate over a list you do something along the lines of:
But this fails (silently, of course) for dictionaries and the magic you are looking for is to call .items on the dictionary then iterate key,value across that:
Edit: This is now covered in the django documentation itself.
Artículo original: acá.
{% for item in list%}{{ item }}{% endfor %}
But this fails (silently, of course) for dictionaries and the magic you are looking for is to call .items on the dictionary then iterate key,value across that:
{% for key,value in dictionary.items %}{{ value }}{% endfor %}
Edit: This is now covered in the django documentation itself.
Artículo original: acá.
Suscribirse a:
Entradas (Atom)