| 20 | |
| 21 | EDIT: |
| 22 | Adding `model_class()` to `ContentType` makes it work |
| 23 | |
| 24 | {{{ |
| 25 | def create_normal_users_group(apps, *args): |
| 26 | auth = SimpleNamespace(**apps.all_models['auth']) |
| 27 | myapp = SimpleNamespace(**apps.all_models['myapp']) |
| 28 | ContentType = apps.get_model('contenttypes', 'ContentType') |
| 29 | # this makes it work ========================= |
| 30 | def model_class(self): |
| 31 | return apps.get_model(self.app_label, self.model) |
| 32 | ContentType.model_class = model_class |
| 33 | # ======================================== |
| 34 | group = auth.group.objects.create(name='Normal Users') |
| 35 | contenttypes = ContentType.objects.get_for_models(myapp.user, myapp.proxy) # there are more models... |
| 36 | # ... |
| 37 | }}} |