question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Namespaces not taken into account

See original GitHub issue

I wanted to distill views from an app (via python manage.py distill-local), but I think distill does not take namespaces into account… I tried with following setup:

# base urls.py
urlpatterns = [
    ...
    path("", include("djagora.map.urls", namespace="map")),
]

# map/urls.py
app_name = "map"

urlpatterns = [
    ...
    distill_path(
        "some_view/",
        view=views.SomeView.as_view(),
        name="some",
    ),
]

But this lead to an error when generating uri: https://github.com/meeb/django-distill/blob/ea6132b6c21c73265c5b80389c9fb448c9eb7297/django_distill/renderer.py#L81 as view_name only contains "some", but correct reverse name would be "map:some". After setting view_name = "map:some" within debugging mode, script goes on without error (giving me some errors later, but this does not belong here). Can you confirm this error, or am I missing something?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
meebcommented, Nov 14, 2020

In the just pushed commit adds partial namespace support including nested namespaces. The only situation where namespaces are not supported is include()ing the same set of URLs more than once on the same project, which will raise a polite and detailed error. So this is fine:

urlpatterns = [
    path('namespace/',
        include('someapp.urls', namespace='namespace')),
    path('namespace/',
        include('anotherapp.urls', namespace='anothernamespace')),
]

But this will throw an error:

urlpatterns = [
    path('namespace/',
        include('someapp.urls', namespace='namespace')),
    path('namespace2/
        include('someapp.urls', namespace='namespace2')),
]

As in, including someapp.urls more than once in the same project. Different URLs are fine. This is because the only sane way to map URLs to their namespace is to use the URL function itself (which matches the id(urlfunc) in most Python interpreters). The second example would reference the same URL more than once, making it impossible to work out which namespace it belongs to. Hopefully this partial implementation is sufficient for all but the most unusual deployments.

1reaction
meebcommented, Nov 6, 2020

I’ll write a test case to check for namespaced inclusion and push any fixes into the next distill release when I get a moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespaces
In Kubernetes, namespaces provides a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique ...
Read more >
Namespaces not found by the compiler - c++
Then in one of the files I am trying to incorporate the classes from the others. The issue is that the compiler seems...
Read more >
The Trouble with Namespaces - Spatial's Blog
The first thing to make clear is that I am NOT saying that namespaces are bad. The fundamental problem that namespaces solve is...
Read more >
Namespaces - cppreference.com
Namespaces provide a method for preventing name conflicts in large projects. Symbols declared inside a namespace block are placed in a named ...
Read more >
XML Schema: Understanding Namespaces
Moving to XML Schema? This introduction to namespaces will help you understand one of its more important elements.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found