So finally, I had a solution. I debugged a lot on django and obviously below the function (with django.contrib.auth.backends ) it does the task of granting permissions.
def _get_permissions(self, user_obj, obj, from_name): """ Returns the permissions of `user_obj` from `from_name`. `from_name` can be either "group" or "user" to return permissions from `_get_group_permissions` or `_get_user_permissions` respectively. """ if not user_obj.is_active or user_obj.is_anonymous() or obj is not None: return set() perm_cache_name = '_%s_perm_cache' % from_name if not hasattr(user_obj, perm_cache_name): if user_obj.is_superuser: perms = Permission.objects.all() else: perms = getattr(self, '_get_%s_permissions' % from_name)(user_obj) perms = perms.values_list('content_type__app_label', 'codename').order_by() setattr(user_obj, perm_cache_name, set("%s.%s" % (ct, name) for ct, name in perms)) return getattr(user_obj, perm_cache_name)
What is the problem?
The problem is with this query:
INSERT INTO django_content_type(name, app_label, model) values ('linked_urls',"urls", 'linked_urls');
It looks fine, but the actual executed request:
--# notice the caps case here - it looked so trivial, i didn't even bothered to look into it untill i realised what was happening internally INSERT INTO django_content_type(name, app_label, model) values ('Linked_Urls',"urls", 'Linked_Urls');
So, django, internally, when migrate executed, ensures that everything is lowercase - and that was the problem!
I had a separate request executed for the lower case of all previous inserts and voila!