Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion elasticapm/contrib/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from django import VERSION as DJANGO_VERSION

from elasticapm.contrib.django.client import * # noqa E401

default_app_config = "elasticapm.contrib.django.apps.ElasticAPMConfig"
if DJANGO_VERSION < (3, 2):
default_app_config = "elasticapm.contrib.django.apps.ElasticAPMConfig"
11 changes: 11 additions & 0 deletions tests/contrib/django/django_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,3 +1604,14 @@ def test_django_ignore_transaction_urls(client, django_elasticapm_client):
django_elasticapm_client.config.update(1, transaction_ignore_urls="/no*")
client.get("/no-error")
assert len(django_elasticapm_client.events[TRANSACTION]) == 1


def test_default_app_config_present_by_version():
# The default_app_config attribute was deprecated in Django 3.2
import elasticapm.contrib.django

default_app_config_is_defined = hasattr(elasticapm.contrib.django, "default_app_config")
if django.VERSION < (3, 2):
assert default_app_config_is_defined
else:
assert not default_app_config_is_defined