Skip to content

Conversation

@anentropic
Copy link

@anentropic anentropic commented Dec 4, 2025

A minimal change to achieve what I needed in #1615 without changing any core functionality

I have tried this in my project and seems to work fine, I am able to do:

    path("app-a/", include("apps.a.urls", namespace="a")),
    path("app-b/", include("apps.b.urls", namespace="b")),

where apps.a.urls and apps.b.urls both look like:

api = NinjaAPI(urls_namespace="reports")
...
urlpatterns = [
    path("other", other.view, name="other"),
    path("", api.urls),
]

and then I can reverse url names like a:reports:api-view, b:reports:api-view, or non-ninja views like a:other

(I feel like the registry could probably just be removed entirely, AFAICT it's not doing anything useful)

Comment on lines +104 to +107
def test_validates(settings):
delattr(settings, "NINJA_SKIP_REGISTRY")
with pytest.raises(ConfigError):
_urls = NinjaAPI().urls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test differs from the old one by not setting NINJA_SKIP_REGISTRY back.

Copy link
Author

@anentropic anentropic Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest-django settings fixture does that automatically... accepting the fixture behaves a bit like if the test case was wrapped in a context manager

(If it wasn't getting restored then many other tests would fail)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants