20/05: Dark shadows

Category: Movies
Posted by: nickapos
The last film by Tim Burton and Johnny Depp.
It is a dark-ish well made film, sometimes it is funny other times it is weird, with some weak spots in the scenario.

Anyway the Burton has done a great job and it is a quite enjoyable film.
Category: Technology
Posted by: nickapos
Storing additional information about users

If you'd like to store additional information related to your users, Django provides a method to specify a site-specific related model -- termed a "user profile" -- for this purpose.

To make use of this feature, define a model with fields for the additional information you'd like to store, or additional methods you'd like to have available, and also add a OneToOneField named user from your model to the User model. This will ensure only one instance of your model can be created for each User. For example:

from django.contrib.auth.models import User

class UserProfile(models.Model):
# This field is required.
user = models.OneToOneField(User)

# Other fields here
accepted_eula = models.BooleanField()
favorite_animal = models.CharField(max_length=20, default="Dragons.")

To indicate that this model is the user profile model for a given site, fill in the setting AUTH_PROFILE_MODULE with a string consisting of the following items, separated by a dot:

The name of the application (case sensitive) in which the user profile model is defined (in other words, the name which was passed to manage.py startapp to create the application).
The name of the model (not case sensitive) class.

For example, if the profile model was a class named UserProfile and was defined inside an application named accounts, the appropriate setting would be:

AUTH_PROFILE_MODULE = 'accounts.UserProfile'

When a user profile model has been defined and specified in this manner, each User object will have a method -- get_profile() -- which returns the instance of the user profile model associated with that User.

The method get_profile() does not create a profile if one does not exist. You need to register a handler for the User model's django.db.models.signals.post_save signal and, in the handler, if created is True, create the associated user profile:

# in models.py

from django.contrib.auth.models import User
from django.db.models.signals import post_save

# definition of UserProfile from above
# ...

def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)

post_save.connect(create_user_profile, sender=User)

19/05: Web radio

Category: General
Posted by: nickapos
For the last months I am following absolute radio from UK.
They have a very nice web player if you can not find the stream yourself here
Category: Technology
Posted by: nickapos
Check it out here

and here
Category: Technology
Posted by: nickapos
here a very good presentation of all the extra commands.
Category: Technology
Posted by: nickapos
pip install Django==1.3.1
pip install django-extensions
pip install django-debug-toolbar
pip install mysql-python
pip install Werkzeug
pip install south
Category: Technology
Posted by: nickapos
How to do it here

and here

and a generic django.wsgi here
Category: Technology
Posted by: nickapos
a nice blog post here

and another one here
Category: Technology
Posted by: nickapos
The project web site: http://www.sqlalchemy.org/
Category: Technology
Posted by: nickapos
Here, the basic question covered is how can a PHP programmer cross over to Python web development.