During the development of a Django model on your local machine is it often necessary to refine the most recent migration to cope with updates to the model, without polluting the migrations of the app with a new migration for each local update.
South had the update flag for the schemamigration command, but I didn’t find a similar functionality in the Django builtin makemigrations command introduced in Django 1.7.
So I put togheter a simple bash script to automate the process.
My latest hybrid app, CoolKids, let you track good and bad actions of your kids to help them in self-improving. I thought it would be nice to share kids achievements with family and friends on social networks, emails, IM, etc. This post shows how I did it.
Recently I had a problem of memory usage in Django: when I accessed an apparently innocent view I saw the memory usage of my server grow without rest. The problem turned out to be very trivial to solve, but I think the process I used to find the leak is worth a blog post. 😉
Assume that you have a Django project where each user belongs to just one group, say Registered or Admin, but not both.
You want to show a form in your front-end to let Admin users edit the user profiles, where each user profile is made with First name, Last name, Email and the user group.
This task can be accomplished very easily! What you need is a customized ModelForm to add the possibility to edit the user group together with the other fields, and a customized UpdateView to let you set the form initial data for the group field, and to save the changes correctly.