Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. To change a field name in django 1.7+
  2.  
  3. 1. Edit the field name in the model (but remember the old field name: you need it for step 3!)
  4. 2. Create an empty migration
  5. $ python manage.py makemigrations --empty myApp
  6. 3. Edit the empty migration (it's in the migrations folder in your app folder, and will be the most recent migration) by adding
  7.  
  8. migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'),
  9.  
  10. to the operations list.
  11.  
  12. 4. Apply the migration
  13. $ python manage.py migrate myApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement