Using Django 2.2 and Python 3.9

When I try to use reverse() for testing one of my apps, it fails. All the
others seem to work OK.

An example code snippet:

from django.test import TestCase

class TestCaseSimple(TestCase):

    def setUp(self):
        User.objects.create_superuser(
            username='t...@example.com',
            password='password',
        )

    def test_test(self):
        self.login = self.client.login(username='t...@example.com',
password='password')
        assert self.login is True
        url = reverse('admin:appone_modelone_changelist')
        print(url)  # passes
        url = reverse('admin:apptwo_modeltwo_changelist')
        print(url)  # fails

Part of error response:

E       django.urls.exceptions.NoReverseMatch: Reverse for
'apptwo_modeltwo_changelist' not found. 'apptwo_modeltwo_changelist' is not
a valid view function or pattern name.

/home/derek/miniconda3/envs/tp32/lib/python3.9/site-packages/django/urls/resolvers.py:677:
NoReverseMatch

During normal use, the app behaves fine and any other tests not requiring
reverse all work OK.

What could cause the URLs for this single app not to be found by the
resolver code?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF1Wu3PCBXhAxVgB7aLoYzNbCUXBWeSWyjLnBGX_2%3DWfqo7GEw%40mail.gmail.com.

Reply via email to