django_evolution.mutations.rename_field

Mutation that renames a field on a model.

New in version 2.2.

Classes

RenameField(model_name, old_field_name, ...)

A mutation that renames a field on a model.

class django_evolution.mutations.rename_field.RenameField(model_name, old_field_name, new_field_name, db_column=None, db_table=None)

Bases: BaseModelFieldMutation

A mutation that renames a field on a model.

Changed in version 2.2: Moved into the django_evolution.mutations.rename_field module.

simulation_failure_error = 'Cannot rename the field "%(field_name)s" on model "%(app_label)s.%(model_name)s".'
__init__(model_name, old_field_name, new_field_name, db_column=None, db_table=None)

Initialize the mutation.

Parameters:
  • model_name (unicode) – The name of the model to add the field to.

  • old_field_name (unicode) – The old (existing) name of the field.

  • new_field_name (unicode) – The new name for the field.

  • db_column (unicode, optional) – The explicit column name to set for the field.

  • db_table (object, optional) – The explicit table name to use, if specifying a ManyToManyField.

get_hint_params()

Return parameters for the mutation’s hinted evolution.

Returns:

A list of parameter strings to pass to the mutation’s constructor in a hinted evolution.

Return type:

list of unicode

simulate(simulation)

Simulate the mutation.

This will alter the database schema to rename the specified field.

Parameters:

simulation (Simulation) – The state for the simulation.

Raises:

django_evolution.errors.SimulationFailure – The simulation failed. The reason is in the exception’s message.

mutate(mutator, model)

Schedule a field rename on the mutator.

This will instruct the mutator to rename a field on a model. It will be scheduled and later executed on the database, if not optimized out.

Parameters:
  • mutator (django_evolution.mutators.ModelMutator) – The mutator to perform an operation on.

  • model (MockModel) – The model being mutated.