code: def get_primary_key(model):
      
      model = get_model(model)
      return (field.name for field in model._meta.fields if field.primary_key).next()
docs: Get the name of the field in a model that has primary_key=True