elbear
elbear

Reputation: 769

How to have nested url namespaces with a dynamic first part in Django

I have an application which is centered around rooms. These rooms have members who can post content in them. The way I thought of having the url patterns would be something like this

# global urls.py
    (r'^g/', include('elearning.apps.rooms.urls', namespace='rooms')),

# rooms urls.py
    url(r'^(?P<room_slug>[-\w]+)/postari/',
        include('elearning.apps.posts.urls', namespace='posts')),

# posts urls.py
    url(r'^adauga/$', 'add', name='add'),

My issue is that I don't know how I can reverse the URL of a view from the 'posts' app. Doing

reverse('rooms:posts:add', kwargs={'room_slug': room.slug})

raises a NoReverseMatch error, probably because 'room_slug' is matched agains the 'add' view's URL pattern.

How can I do this?

Thanks

Upvotes: 4

Views: 1234

Answers (1)

elbear
elbear

Reputation: 769

Looks like this has been fixed recently. https://code.djangoproject.com/changeset/16608

Upvotes: 1

Related Questions