ixc / wagtail-instance-selector

A widget for Wagtail's admin that allows you to create and select related items
MIT License
54 stars 17 forks source link

`default_app_config` in `__init__.py` deprecated since Django 3.2 #23

Closed tbrlpld closed 2 years ago

tbrlpld commented 2 years ago

Since Django 3.2 it is not necessary anymore to declare a default_app_config is only a single app config is present in the apps.py.

With that declaration, Django throws deprecation warnings like so:

/venv/lib/python3.8/site-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'instance_selector' defines default_app_config = 'instance_selector.apps.AppConfig'. Django now detects this configuration automatically. You can remove default_app_config.

Possible solution

Only define default_app_config for Django versions before 3.2.

# __init__.py
import django 

if django.VERSION < (3, 2):
    default_app_config = "%s.apps.AppConfig" % __name__

See also https://docs.djangoproject.com/en/3.2/releases/3.2/#automatic-appconfig-discovery

markfinger commented 2 years ago

Thanks for the heads up. Your proposed solution sounds perfect 👍

Can you open a PR with the changes?

tbrlpld commented 2 years ago

@markfinger I have added #24 for your consideration 😄