Соответствующий запрос ContentType не существует в post_syncdb

Я пытаюсь добавить добавить некоторые данные в базу данных, как только создаются таблицы, используяpost_syncdb сигнал.

signals.post_syncdb.connect(init)

Затем в функции инициализации я хочу установить разрешение, поэтому я использую

ct = ContentType.objects.get(app_label='news', model='Article')
Permission(name='Approve articles', codename='can_approve_article', content_type=ct)

Но если я отброшу все таблицы и запустлюsyncdb, Я получил

...
File "...\base\functions\init.py", line 11, in init
  ct = ContentType.objects.get(app_label='news', model='Article')
...
django.contrib.contenttypes.models.DoesNotExist: ContentType matching query does not exist.

Некоторые тесты, которые я сделал:

It works fine if I try this code outside syncdb. It also works fine if I let syncdb create all the tables without this code, and then add this code and run syncdb without it having to make any changes. AND I am pretty sure it used to work, but I changed a lot of things in other places since then, so I don't know where to start. I get the same error for other models in different apps. The signal is fired about 10 times, only the first few times throw the error.

Большое спасибо за любые подсказки!

Ответы на вопрос(1)

Ваш ответ на вопрос