RkBlog

A note on Django 1.5.2 rotating CSRF token and frontend javascript applications

Django 1.5.2 introduced a change named The CSRF token now rotates when a user logs in. This isn't anything problematic for typical web applications where user submits a form and the page reloads. For applications that are based on JavaScript frameworks like ember (or angular) this becomes a problem, as the user is logged in the background with an AJAX request (for example with Facebook JS SDK) and the page in general never reloads. When he logs in the token changes and API (POST) requests (to django-rest-framework for example) will get forbidden as answers from the server.

A solution would be to return a new token with server response to the login request and insert it in the place of the old one, which was inserter when Django template was rendered:
xhr.setRequestHeader("X-CSRFToken", "{{csrf_token}}"); 
I wonder if there are any solutions for this already?

› Read more

Switching power with transistors, relays and microcontrollers

Simplest way to automate, control electronic devices is to turn them on or off with an electronic switch. We can find relays or transistors that when combined with a microcontroller board can switch power delivered to selected devices. In this article I'll showcase both components and examples of usage with pyMCU microcontroller.

› Read more

Testing small external lenses for phones and other mobile devices

China can make quite interesting gadgets like for example external lenses for phones and other devices. They alter how the built-in lens works allowing for wide field, macro or telephoto effect. Some will even give you fish-eye ultra wide field effect. Such lenses cost few Euros and are quite basic in design. I'll take a look at two of them - 2x telephoto and macro/wide field lens.

› Read more

django-ckeditor-updated released with Django 1.6 and storage API

django-ckeditor repository wasn't updated from a long time and a lot of issues collected. With the release of Django 1.6 django-ckeditor stopped working due to "defaults" in urls.py import. I've decided to polish and release my fork as a pypi package to make it easier to install the newer version. You can install it via pip using django-ckeditor-updated as name. Current version is 4.2.1.

Biggest change compared to the upstream is Django storage API usage for file uploads (to make it easier to configure and to allow using other backends than local folder - like S3 storage). Other updates give CKEditor 4.2.1 as well as Django 1.6 support (should also work on 1.4 and 1.5).

This application gives you the CKEditor on a model field in Django admin or in your forms. The editor can be configured (interface) and it can upload images (with the help of pillow).

› Read more

Quick and handy wheel package format for Python applications

Python packaging needs some help. A solution to at least some problems may be wheel - a new format for fast and efficient software installation and distribution. It's described in few PEPs and now it's starting to take shape. It was showcased recently on PyCon PL 2013.

There is nearly no wheels on pypi but we can use them locally to make local installations faster (handy for continuous integration systems and alike that build a project from scratch often).

› Read more

Controlling LED arrays with pyMCU microcontroller

LED arrays are quite popular and handy. You can make animated banners, panels displaying text or basic graphics. For a microcontroller turning a LED on and off isn't a problem. However if you would have 64 or more LEDs then it's not that easy. A solution for this problem are LED controllers. They reduce the number of pins needed to manage all the LEDs. Some of those controllers may also implement other features handy for text scrolling etc. In this article I'll showcase 8x8 LED array with MAX7219 controller.

› Read more

Quick look at Allwinner A10 based pcDuino single board computer

pcDuino is one of may single board computers with ARM processor. This one combines relatively low price with some Arduino compatibility. Intended for electronic hacking it's bit more powerful than Raspberry Pi - at least in the specs. There are multiple similar boards in this price/features range so let us see how pcDuino will perform.

› Read more

RkBlog main page Search RSS Contact