I recently started experimenting with Django for some web applications in my free time. When developing a data model for one, I came across the dilemma of using inheritance to define a website user or using a method known as a monkey patch, with the User class already provided by the framework.
I tried to add a field with (after defining all my models etc. without errors, according to python manage.py validate ):
User.add_to_class('location', models.CharField(max_length=250,blank=True))
and executed the syncdb . However, I keep getting this error
OperationalError: no such column: auth_user.location
Whether I am in the administrative view of the site or in the manage.py shell. There should be an extra step that I am missing, but there seems to be limited documentation on the whole technique of patch monkeys. Therefore, I ask you for help before resorting to inheritance. Any code, tips or pointers to additional documentation, of course, are welcome.
Thanks in advance.
PS. I know this technique is ugly and probably not recommended .;)
source share