khashashin
khashashin

Reputation: 1137

Wagtail TypeError: 'parent' is an invalid keyword argument for this function

I got following error and the problem is that I do not know what causes this error, I can not add that whole code. I use method described here Inline Panels and Model Clusters If it is possible to find out what exactly leads to this error, tell me please, and I'll post the code.

Just in case, here is a link to the model. gist

And here is my wagtail_hooks.py. gist2

$ py manage.py check
Traceback (most recent call last):
  File "manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\commands\check.py", line 68, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\urls\resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\xakep\GitHub\treichle_cup\treichle_cup\urls.py", line 7, in <module>
    from wagtail.wagtailadmin import urls as wagtailadmin_urls
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\wagtailadmin\urls\__init__.py", line 14, in <module>
    from wagtail.wagtailadmin.api import urls as api_urls
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\wagtailadmin\api\urls.py", line 13, in <module>
    for fn in hooks.get_hooks('construct_admin_api'):
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\wagtailcore\hooks.py", line 49, in get_hooks
    search_for_hooks()
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\wagtailcore\hooks.py", line 43, in search_for_hooks
    list(get_app_submodules('wagtail_hooks'))
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\utils\apps.py", line 25, in get_app_submodules
    yield name, import_module('%s.%s' % (name, submodule_name))
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\xakep\GitHub\treichle_cup\team_rooster\wagtail_hooks.py", line 47, in <module>
    modeladmin_register(TournamentModelAdmin)
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\contrib\modeladmin\options.py", line 594, in modeladmin_register
    instance = modeladmin_class()
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\wagtail\contrib\modeladmin\options.py", line 522, in __init__
    self.modeladmin_instances.append(ModelAdminClass(parent=self))
  File "C:\Users\xakep\GitHub\treichle_cup\env\lib\site-packages\django\db\models\base.py", line 573, in __init__
    raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])
TypeError: 'parent' is an invalid keyword argument for this function

UPDATE

I found out that is related to wagtail_hooks.py I just removed my TournamentModelAdmin class And if i do check again i didn't get errors.

Upvotes: 0

Views: 437

Answers (1)

khashashin
khashashin

Reputation: 1137

As @lb-ben-johnston said my mistake was that I directly added the model. So I just changed my code from that:

class TournamentModelAdmin(ModelAdminGroup):
    menu_label = 'Tournament'
    menu_icon = 'folder-open-inverse'
    menu_order = 500
    items = (GoupstageTournamentModel,
        FinalphaseTournamentModel, TournamentPage)

modeladmin_register(TournamentModelAdmin)

To:

class TournamentModelAdmin(ModelAdmin):
    model = TournamentPage
    menu_label = 'Tournament'
    menu_icon = 'fa-trophy'
    list_display = ('starts_at', 'ends_at')
    list_per_page = 5
    search_fields = ('title', 'starts_at')

class GroupstageModelAdmin(ModelAdmin):
    model = GroupstageTournamentModel
    menu_label = 'Gruppenphase'
    menu_icon = 'fa-user-times'
    list_display = ('number', 'starts_at',
        'team_1_dress', 'team_1', 'team_1_total_score', 'team_1_total_points',
        'team_2_total_points', 'team_2_total_score', 'team_2', 'team_2_dress')
    list_per_page = 10
    list_filter = ('number', 'starts_at')
    search_fields = ('number', 'starts_at')

class FinalstageModelAdmin(ModelAdmin):
    model = FinalphaseTournamentModel
    menu_label = 'Finalphase'
    menu_icon = 'fa-user-plus'
    search_fields = ('number', 'starts_at')   

class TreichleCupModelAdmin(ModelAdminGroup):
    menu_label = 'Treichle-Cup'
    menu_icon = 'folder-open-inverse'
    menu_order = 200
    items = (
        TournamentModelAdmin,
        GroupstageModelAdmin,
        FinalstageModelAdmin,
    )

modeladmin_register(TreichleCupModelAdmin)

And its works well! Thanks @lb-ben-johnston

Upvotes: 3

Related Questions