Beyond the Basics of Migrations with Charlotte Mays

Learn how to make the most of Django's migration system with expert Charlotte Mays, covering essential best practices and pitfalls to avoid in model changes, field definitions, and more.

Key takeaways
  • Use get_model to retrieve the correct model version, rather than importing models directly.
  • When making changes to a model, make sure to use the get_model function to ensure the changes are applied correctly.
  • When running migrations, use migrations.runPython.noop instead of migrations.runPython without the noop parameter to avoid unexpected behavior.
  • When creating a new model, use the correct field definition to avoid importing the wrong model.
  • When renaming a field or model, use RenameField instead of directly modifying the field definition.
  • When making changes to a field, use the correct field type and attributes to ensure the changes are applied correctly.
  • When using runPython, use the noop parameter to indicate that no reverse operation is needed.
  • When creating a new migration, include a logical name and use the get_model function to retrieve the correct model version.
  • Use the get_model function to retrieve the correct model version, rather than importing models directly.
  • Before making changes to a model, check that the changes will not conflict with other migrations.
  • When creating a new model, use the correct field definition to avoid importing the wrong model.
  • When renaming a field or model, use RenameField instead of directly modifying the field definition.
  • When making changes to a field, use the correct field type and attributes to ensure the changes are applied correctly.
  • When using runPython, use the noop parameter to indicate that no reverse operation is needed.
  • When creating a new migration, include a logical name and use the get_model function to retrieve the correct model version.