django_evolution.mutations.delete_field

Mutation for deleting fields from a model.

New in version 2.2.

Classes

DeleteField(model_name, field_name)

A mutation that deletes a field from a model.

class django_evolution.mutations.delete_field.DeleteField(model_name, field_name)

Bases: BaseModelFieldMutation

A mutation that deletes a field from a model.

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

simulation_failure_error = 'Cannot delete the field "%(field_name)s" on model "%(app_label)s.%(model_name)s".'
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 remove the specified field, modifying meta fields (unique_together) if necessary.

It will also check to make sure this is not a primary key and that the field exists.

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 deletion on the mutator.

This will instruct the mutator to perform a deletion of 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.