Django on Azure App Service: got an unexpected keyword argument allow_abbrev

I am deploying a Saas with Django 5.2.10 application on Azure App Service (Linux). During container startup, my startup script runs database migrations before launching gunicorn. The container crashes immediately when any management command is executed.

The error occurs even with the simplest command like python manage.py migrate. It fails before Django even loads the settings file.

Full traceback:

Traceback (most recent call last):
  File "/home/site/wwwroot/manage.py", line 22, in <module>
    main()
  File "/home/site/wwwroot/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File ".../django/core/management/__init__.py", line 366, in execute
    parser = CommandParser(
        prog=self.prog_name,
        allow_abbrev=False,
    )
  File ".../django/core/management/base.py", line 64, in __init__
    super().__init__(**kwargs)
TypeError: ArgumentParser.__init__() got an unexpected keyword argument 'allow_abbrev'

Environment:

  • Python: 3.13.11 (Azure image appsvc/python:3.13_20260203.2.tuxprod)
  • Django: 5.2.10
  • Hosting: Azure App Service on Linux

What I already checked:

I confirmed that allow_abbrev is a valid argparse parameter since Python 3.5, so Python 3.13 should support it natively. I also verified that all relevant packages import without errors. Running this in the startup script before the crash confirms everything loads fine:

python -c "import django; print(django.__version__)"
python -c "import drf_yasg; print('ok')"

Both return successfully. The crash only happens when a management command is invoked, specifically at the point where Django instantiates CommandParser.

What I tried:

I removed potentially conflicting packages (dotenv==0.9.9, drf-yasg) one by one, but the error persisted. The issue is not caused by any dependency conflict.

Root cause I found:

The Azure App Service Python 3.13 runtime image (appsvc/python:3.13_20260203.2.tuxprod) appears to ship with a patched or broken version of argparse that does not accept allow_abbrev as a keyword argument to ArgumentParser.__init__(). Django 5.2 passes this argument internally inside CommandParser, which is standard Python behavior.

Has anyone else hit this with the Azure Python 3.13 image? Is there a workaround that keeps Python 3.13 adn Django?

Вернуться на верх