reverse throwing NoReverseMatch exception

My project structure looks like this:

├───apps
│ │ init.py
│ │
│ ├───student_data
│ │ │ admin.py
│ │ │ apps.py
│ │ │ models.py
│ │ │ permissions.py
│ │ │ serializers.py
│ │ │ urls.py
│ │ │ views.py
│ │ │ init.py
│ │ │
│ │ │
│ │ ├───tests
│ │ │ │ test_student_data.py
│ │ │ │ init.py


└───core
│ asgi.py
│ storage_backends.py
│ urls.py
│ wsgi.py
init.py

├───settings
│ │ .env
│ │ development.py
│ │ production.py

This is core.urls.py :

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('apps.student_data.urls', namespace='student_data'))
]

This is apps.student_data.urls.py :

app_name = 'apps.student_data'

router = DefaultRouter()

router.register(r'student_data', StudentDataViewSet)

urlpatterns = [
    path('', include((router.urls, 'student_data'))),
]

I’m trying to get the student_data URL from my tests.py like this:

reverse('apps.student_data:student_data')

But I keep getting: django.urls.exceptions.NoReverseMatch: Reverse for ‘student_data’ not found. ‘student_data’ is not a valid view function or pattern name.

I’ve tried every combination of name, namespace, appname I could think of but none of them work.

Solved: I had to set a basename while registering the router.