Opened 2 years ago

Last modified 4 months ago

#28752 closed Cleanup/optimization

Django.setup() should be idempotent — at Initial Version

Reported by: pascal chambon Owned by: nobody
Component: Core (Other) Version: 1.11
Severity: Normal Keywords:
Cc: Aymeric Augustin Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I've been bitten numerous times by the impredictable behaviour of django when django.setup() was called numerous times.

In the old days I had exceptions, now it's mainly subtle breakages of logging configuration.

I couldn't find, in the issue tracker or the dev mailing list statements about this subject, others than request from other users encountering the problem.

For example this ticket concerned script+importable modules :

The latest case in date for me is pytest-django having troubles with these multiple setup() calls : , due to multiple fixtures attempting this auto-setup.

Would it be OK to make django.setup() idempotent, or even expose a "is_ready" flag for easier introspection ?

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top