Changes between Initial Version and Version 1 of Ticket #35813, comment 4
- Timestamp:
- Dec 20, 2024, 7:46:37 AM (42 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35813, comment 4
initial v1 4 4 A mismatch between your code and the database structure may result from this behavior, especially if the model is altered after the initial transfer. 5 5 6 Unmanaged Model:7 6 Consider you have two models in Django: one is unmanaged and the other is managed. 7 {{{#!python 8 8 class UnmanagedThing(models.Model): 9 9 id = models.IntegerField(db_column="thingID", primary_key=True) … … 16 16 db_table = "some_table_name" 17 17 18 Managemed Model 18 19 19 class ManagedThing(models.Model): 20 20 id = models.IntegerField(db_column="thingID", primary_key=True) … … 25 25 class Meta: 26 26 managed = True # This tells Django to manage the table's structure. 27 27 }}} 28 28 Anticipated Conduct: First Migration: Django creates a migration file that records the construction of the managed and unmanaged models when you execute makemigrations for the first time. 29 29 Modifications to the Managed Model: Django recognizes when you change the thing_name in the managed model from a CharField to an IntegerField and generates a migration that takes into account the field change.