Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Shiv - Part Deux
After debating whether to release early or release well, I have settled for the former. I hope that once the code is out in the open and I get ridiculed for the lousy code quality, it will motivate me to find time more aggressively to correct and refine the framework. I will try to find some time to continue my little tutorial of Shiv with sample applications in the next installment. In the meantime, here is the link to the git repository. Have a look and feel free to ask me any question that you might have. https://github.com/lzdev/Shiv Part 1 | Part 3 -
Measure your code
I found a cool tool today to measure code: metrics. It measures SLOC, comments and cyclomatic complexity. It’s easy to install: pip install pygments metrics Run this in your project’s root: metrics -v `find . -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` I have a django project so I added \! -path "*/migrations/*.py" to skip any files that are in a migrations dir (I’d skip the automatically generated south migrations). You probably bundle other libraries or apps in your source tree (eg: jquery or that nice django app the author didn’t bother to make a setup.py script for) so you want to measure only some specific paths. Eg, to collect stats only for files in src/foobar, lib/tools and src/otherbar: metrics -v `find src/foobar lib/tools src/otherbar -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` If you work on multiple projects you can make a script or alias for this: metrics -v `find \`cat METRICS\` -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) … -
Measure your code
I found a cool tool today to measure code: metrics. It measures SLOC, comments and cyclomatic complexity. It's easy to install: pip install pygments metrics Run this in your project's root: metrics -v `find . -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` I have a django project so I added \! -path "*/migrations/*.py" to skip any files that are in a migrations dir (I'd skip the automatically generated south migrations). You probably bundle other libraries or apps in your source tree (eg: jquery or that nice django app the author didn't bother to make a setup.py script for) so you want to measure only some specific paths. Eg, to collect stats only for files in src/foobar, lib/tools and src/otherbar: metrics -v `find src/foobar lib/tools src/otherbar -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` If you work on multiple projects you can make a script or alias for this: metrics -v `find \`cat METRICS\` -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) … -
Measure your code
I found a cool tool today to measure code: metrics. It measures SLOC, comments and cyclomatic complexity. It's easy to install: pip install pygments metrics Run this in your project's root: metrics -v `find . -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` I have a django project so I added \! -path "*/migrations/*.py" to skip any files that are in a migrations dir (I'd skip the automatically generated south migrations). You probably bundle other libraries or apps in your source tree (eg: jquery or that nice django app the author didn't bother to make a setup.py script for) so you want to measure only some specific paths. Eg, to collect stats only for files in src/foobar, lib/tools and src/otherbar: metrics -v `find src/foobar lib/tools src/otherbar -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) \! -path "*/migrations/*.py" -print` If you work on multiple projects you can make a script or alias for this: metrics -v `find \`cat METRICS\` -type f \( -iname "*.css" -or -iname "*.py" -or -iname "*.js" -or -iname "*.html" -or -iname "*.txt" \) … -
Be careful how you use static variables in forms
Working on django-uni-form I came across with a weird situation and it took me some time to figure out what was going on. I wouldn’t say it was a bug, it was more a misuse or a documentation problem. After that, I realized other coders make the same mistake that was affecting us, so I thought about writing an article for warning Python/Django programmers. If you are building a Django application in which you add attributes to a form, that are not form fields, like in this example: class ExampleForm(forms.Form): description = forms.CharField( label = u"Short description", max_length = 40, ) type_of_form = 'dangerous' You should know that every attribute that is not a form field, such as type_of_form, is static or a class-wide variable. Let’s see what this means and please stay with me till the end, don’t switch channel. If you handle a form instance in one of your views and change type_of_form value: form = ExampleForm(request.POST) form.type_of_form = "secure" Then type_of_form turned into an instance-level variable. Which means only that specific form instance has a type_of_form set to ‘secure’. You can still access the class wide variable, using the class name: >>> ExampleForm.type_of_form 'dangerous' Things get complicated … -
Be careful how you use static variables in forms
Working on django-uni-form I came across with a weird situation and it took me some time to figure out what was going on. I wouldn’t say it was a bug, it was more a misuse or a documentation problem. After that, I realized other coders make the same mistake that was affecting us, so I thought about writing an article for warning Python/Django programmers. If you are building a Django application in which you add attributes to a form, that are not form fields, like in this example: class ExampleForm(forms.Form): description = forms.CharField( label = u"Short description", max_length = 40, ) type_of_form = 'dangerous' You should know that every attribute that is not a form field, such as type_of_form, is static or a class-wide variable. Let’s see what this means and please stay with me till the end, don’t switch channel. If you handle a form instance in one of your views and change type_of_form value: form = ExampleForm(request.POST) form.type_of_form = "secure" Then type_of_form turned into an instance-level variable. Which means only that specific form instance has a type_of_form set to ‘secure’. You can still access the class wide variable, using the class name: >>> ExampleForm.type_of_form 'dangerous' Things get complicated … -
DjangoCon Europe videos posted
DjangoCon Europe 2011 videos online A bit late to the game perhaps, since people already started tweeting links to the videos before me having time to actually link the videos to the talks. But hey, that shouldn’t spoil the game: The videos are now online, and can be found in te schedule on the details pages of all the talks, including the slides. For example to check out Eric Florenzano’s excellent opening keynote, check out this talk page. The video of Alex’ talk on monday is forthcoming. I would like to use the opportunity to thank our Kryptonite sponsors, who made such a large contribution to DjangoCon Europe 2011, once more: Fabrique: Who in addition to being a kryptonite sponsor also sponsored the cocktail bar on Monday and the massages/relaxing area on Tuesday. I amsterdam: Who in addition to being a kryptonite sponsor also sponsored the free bikes for conference goers and the massages during both the sprint days. A warm thank you from all of us. -
Award Winning Satchmo Sites
The team at Pemaquid Communications have been successfully using Satchmo and Django to create innovative sites for their clients. Recently they won several Best of the Web awards at the TechMaine Gala. -
Documenting Django pluggable apps with Sphinx
I decided to document my Django projects with the same tool used by Django team: Sphinx. It is a very good documenting tool, and was used for many other projects, including the Python Project itself. But it has a simple problem with Django, that I found the solution rlazo’s blog. But it still has some problems, [...] -
Reffering to Django docs from your docs using Sphinx
Sphinx is a great documentation tool, and one of it’s built-in extensions is sphinx.ext.intersphinx. It simply takes your objects references for other projects and converts to links in the other project’s documentation. In sphinx-quickstart command, it asks if you want to add this extension. If so, It adds this code to your conf.py file: extensions = ['sphinx.ext.intersphinx'] intersphinx_mapping [...] -
django-meio-easytags released!
django-meio-easytags An easy way to create and parse custom template tags for Django's templating system. -
Django ORM now supports fields references in filters
Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it. Before this update, queryset could be filtered only by absolute values. queryset.filter(field='absolute value') Will generate somthing like this: SELECT * FROM table_name WHERE field = 'absolute value'; Now you can filter by another’s table [...] -
MEDIA_URL and context from processors available in HTTP 500 template
It’s easy to create a custom template for HTTP 500 errors. All you have to do is create a file named 500.html in any of the application’s TEMPLATE_DIRS. But in almost all cases you want to use media in this page. It’s good to have an error page with the same look and feel of [...] -
Festival Latino-americano de Instalação de Software Livre
Venho através deste convidá-los ao FLISOL/RN 2009. O Festival Latino-americano de Instalação de Software Livre do RN irá acontecer no dia 25 de abril de 2009 no SENAC em Natal. No evento eu irei ministrar um mini-curso introdutório ao framework Django das 14:00 as 17:00 horas, cujo objetivo é formar pessoas com conhecimentos básicos acerca do [...] -
Arquivos do Mini curso de Django disponibilizados
No dia 24 de abril de 2009, no SENAC em Natal/RN, ocorreu o FLISOL. Neste evento, eu ministrei um mini curso de django. Então estou disponibilizando tanto os arquivos_mini_curso desenvolvido durante o curso, como os slides. Mini curso introdutório ao DjangoView more presentations from vbmendes. -
get_first_object_or_none shortcut for Django
I will talk about a shortcut I developed for the Django framework and always use in my apps. This code is aimed in making a quik shortcut to obtain the first object of a queryset if it exists or None otherwise. It’s very useful when you want to display the last news in the first page [...] -
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 -
django-meio-easytags 0.3 released!
I released today the version 0.3 of django-meio-easytags. Now it supports template tags that accepts positional arguments (*args) and keyword arguments (**kwargs). If you don’t know how to use this, take a look at Python FAQ. In this release I included some documentation and created a page for the project. Any doubts, suggestions, feature requests, feel [...] -
Django’s dev server and UTF-8
From time to time I got this UnicodeEncodeError, but I had done all the things (sitecustomize.py, some more) right in order to configure the system in UTF-8. I thought. I did the usual ./manage runserver and since I assumed that on my Mac everything is already properly configured ... -
JavaScript: Sort object by a value
Actually the headline is not really what I want to say :-). But I don't know any better yet. I just want to write down how I solved sorting the following: >>> var maxSpeed = {car:300, bike:60, motorbike:200, airplane:1000, helicopter:400, rocket:8*60*60} This is a list of vehicles with their (approx.) ... -
Mayflower Barcamp - awesome!
Mayflower had invited me to join their Barcamp last weekend - and it was awesome. Thank you a lot!!! We had been a crowd of about 40 people all hacking all day long until deep at night, it was a great atmosphere and some very interesting projects had been made. ... -
Just for always and for ever be with me
Idén is, ahogy már tavaly is, noha ezúttal új köntösben, van szerencsém bemutatni az érdeklődő hallgatóságnak a webes technológiák egy éppen aktuális gyöngyszemét. A 2006-os Magyarországi Web Konferencián Django: Python on Rails címmel fogok előadást tartani. 17-én, szombaton 22.00-kor a Love Alliance Soundsystem lép fel a Sarkban. Február 23-án pedig a ... -
Django/Dojo Stammtisch in Berlin
For the second time Django enthusiasts are meeting in Berlin on Wednesday, the 15th April, 2009 at 19:30. Find all the details here. And since I will be in Berlin this time, I just simply redeclare this to "Django/Dojo Stammtisch" instead of just "Django Stammtisch" :-). I hope all the ... -
Adobe Air Tour Europe stopped in Munich
Fortunately Tobias found out one day before that Adobe was touring with Air and coming to Munich. Adobe really had provided everything, from breakfast, drinks, lunch too I guess (we weren't there) and beer afterwards (that we didn't miss). It was really impressive. The talks were very Air focused, I ... -
Customize admin for User model
Before django 1.0 I don't remember that there was a way to customize how the admin renders the User overview. Fortunately 1.0 does allow it. It took me a bit to figure out. After searching the web and the django docs I didn't find it right away, so I tried the ...