I have a problem with django 1.3, south 0.7.3, not which of them ocacion the problem, but I tell that happens to me:
debuging I see that the problem is that in a migration try add the permission 'Can add profile' again and the table constraint auth_permission does not allow it and raise.
Viewing source for south found nothing, and seeing the source of django I found this fragment in which I found a problem, but I not know his reason
def create_permissions(app, created_models, verbosity, **kwargs):
from django.contrib.contenttypes.models import ContentType
app_models = get_models(app)
# This will hold the permissions we're looking for as
# (content_type, (codename, name))
searched_perms = list()
# The codenames and ctypes that should exist.
ctypes = set()
for klass in app_models:
ctype = ContentType.objects.get_for_model(klass)
for perm in _get_all_permissions(klass._meta):
# Find all the Permissions that have a context_type for a model we're
# looking for. We don't need to check for codenames since we already have
# a list of the ones we're going to create.
all_perms = set(auth_app.Permission.objects.filter(
for ctype, (codename, name) in searched_perms:
# If the permissions exists, move on.
if (ctype.pk, codename) in all_perms:
p = auth_app.Permission.objects.create(
if verbosity >= 2:
print "Adding permission '%s'" % p
Looking at the result of searched_perms variable, I found repeated permissions
searched_perms: [(<ContentType: profile>, (u'add_profile', u'Can add profile')), (<ContentType: profile>, (u'change_profile', u'Can change profile')), (<ContentType: profile>, (u'delete_profile', u'Can delete profile')), (<ContentType: profile>, ('add_profile', 'Can add profile')), (<ContentType: profile>, ('change_profile', 'Can change profile')), (<ContentType: profile>, ('delete_profile', 'Can delete profile')), (<ContentType: profile>, ('view_profile', 'Can view profile'))].
Converting searched_perms to a set and solve the problem by eliminating repetitions, but completely ignores the cause. (sorry for my bad English)
for ctype, (codename, name) in searched_perms: -------> for ctype, (codename, name) in set(searched_perms):