Помогите пожалуйста.
Есть 2 аппликухи
# app_places from django.db import models class Place(models.Model): movie = models.ManyToManyField('app_shows_and_times.Show', through='app_shows_and_times.Showtime') place_name = models.CharField(max_length=50, db_index=True) place_street = models.CharField('Street', max_length=80) place_phone = models.CharField('Phone', max_length=60) class Meta: db_table = 'place'
# app_shows_and_times from django.db import models class Show(models.Model): show_name = models.CharField(max_length=100, db_index=True) class Meta: db_table = 'show' class Showtime(models.Model): showtime_dates = models.CharField('Date', max_length=30) showtime_times = models.CharField('Time', max_length=30) showtime_place = models.ForeignKey('app_places.Place', verbose_name='Place') showtime_show = models.ForeignKey(Show, verbose_name='Show name') class Meta: db_table = 'showtime'
makemigrations каждой из них проходит на ОК. Делаю migrate и выдает вот такое:
Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv self.execute(*args, **cmd_options) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute output = self.handle(*args, **options) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 146, in handle plan = executor.migration_plan(targets) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/db/migrations/executor.py", line 59, in migration_plan for migration in self.loader.graph.forwards_plan(target): File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/db/migrations/graph.py", line 139, in forwards_plan self.ensure_not_cyclic(node, lambda x: (parent.key for parent in self.node_map[x].parents)) File "/home/antonio/projects/my_site/lib/python3.4/site-packages/django/db/migrations/graph.py", line 196, in ensure_not_cyclic raise CircularDependencyError(", ".join("%s.%s" % n for n in cycle)) django.db.migrations.graph.CircularDependencyError: app_shows_and_times.0001_initial, app_places.0001_initial
Если обе модели сливаю в один файл, migrate проходит на ура. Но я не хочу сливать эти 2 аппликухи в один файл.
Если закомментировать
movie = models.ManyToManyField('app_shows_and_times.Show', through='app_shows_and_times.Showtime')
Благодарю.
________________________________________________________________
РЕШЕНИЕ
1. Комментирую
movie = models.ManyToManyField('app_shows_and_times.Show', through='app_shows_and_times.Showtime')
3. makemigrations app_places -> ok
4. Снимаю комментарий с кода в п.1
5. еще раз makemigrations app_places -> ok
6. migrate -> ok!