Opened 20 months ago

Last modified 13 days ago

#28752 assigned Cleanup/optimization

django.setup() should be idempotent — at Version 5

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

Description (last modified by pascal chambon)

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 :
https://code.djangoproject.com/ticket/26152

The latest case in date for me is pytest-django having troubles with
these multiple setup() calls : https://github.com/pytest-dev/pytest-
django/issues/531 , 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 (5)

comment:1 Changed 20 months ago by Tim Graham

Resolution: duplicate
Status: newclosed
Summary: Django.setup() should be idempotentdjango.setup() should be idempotent

I believe this is addressed in Django 2.0 by #27176. If not, please reopen with a minimal project that reproduces the problem you're encountering.

comment:2 Changed 20 months ago by pascal chambon

Description: modified (diff)
Resolution: duplicate
Status: closednew

comment:3 Changed 20 months ago by Tim Graham

Thanks. Can you explain the use case for calling django.setup() multiple times?

comment:4 Changed 20 months ago by pascal chambon

Description: modified (diff)

comment:5 Changed 20 months ago by pascal chambon

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top