﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20839	models.py module is imported multiple times.	gwahl@…	nobody	"When a models.py module raises an ImportError for whatever reason, Django will attempt to import it many times. This can be demonstrated thus:

{{{
# models.py

print 'loaded'
import nonexistent_module
}}}

'loaded' will be printed more than once. This is due to the 'postponing' behavior during model loading: https://github.com/django/django/blob/master/django/db/models/loading.py#L118. 

This is an issue for me because I have a registry system that tracks models and only allows them to be registered once.

{{{
class WhateverModel(models.Model):
    pass
registry.register(WhateverModel)  # checks that models are only registered once
import nonexistent_module  # oops, now it's registered twice (or more)
}}}"	Cleanup/optimization	closed	Database layer (models, ORM)	1.5	Normal	fixed			Accepted	0	0	0	0	0	0
