Advertisement
Mochinov

Untitled

May 4th, 2022
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. # Generated by Django 3.0.8 on 2021-09-30 12:38
  2.  
  3. import mptt.fields
  4.  
  5. from django.db import migrations, models
  6. import django.db.models.deletion
  7.  
  8. from users.models import Department
  9.  
  10.  
  11. def rebuild_tree(apps, schema_editor):
  12. """Пересобирает данные дерева для Department"""
  13. Department.objects.rebuild()
  14.  
  15.  
  16. class Migration(migrations.Migration):
  17.  
  18. dependencies = [
  19. ('users', '0006_remove_position_department'),
  20. ]
  21.  
  22. operations = [
  23. migrations.AlterModelOptions(
  24. name='department',
  25. options={},
  26. ),
  27. migrations.AddField(
  28. model_name='department',
  29. name='level',
  30. field=models.PositiveIntegerField(default=0, editable=False),
  31. preserve_default=False,
  32. ),
  33. migrations.AddField(
  34. model_name='department',
  35. name='lft',
  36. field=models.PositiveIntegerField(default=0, editable=False),
  37. preserve_default=False,
  38. ),
  39. migrations.AddField(
  40. model_name='department',
  41. name='parent',
  42. field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='users.Department'),
  43. ),
  44. migrations.AddField(
  45. model_name='department',
  46. name='rght',
  47. field=models.PositiveIntegerField(default=0, editable=False),
  48. preserve_default=False,
  49. ),
  50. migrations.AddField(
  51. model_name='department',
  52. name='tree_id',
  53. field=models.PositiveIntegerField(db_index=True, default=0, editable=False),
  54. preserve_default=False,
  55. ),
  56. migrations.RunPython(rebuild_tree),
  57. ]
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement