I'm trying to reuse a wiki app twice in my project; however, whenever I call
the reverse function, it returns the URL of the first instance defined in my
urls.conf.  I have attempted specifying the view name as
app_instance:view_name, app_name:view_name as well as using the current_app
keyword of the reverse function.  I have not had any luck so far and was
hoping for suggestions on what I'm doing wrong.  I've only posted the
relevant parts of the code.

Per the Django documentation on namespacing, I have set up my top-level URLs
conf as:

...
(r'help/', include('test.wiki.urls', 'wiki', 'help'), {'wiki': 'help'}),
(r'learn/wiki/', include('test.wiki.urls', 'wiki', 'learn'), {'wiki':
'learn'}),
...

In my wiki app, the urls.conf has

url(r'^(?P<slug>[-\w]+)/$', 'test.wiki.views.display',
name='wiki_page_detail'),
url(r'^(?P<slug>[-\w]+)/404$', direct_to_template, {'template':
'wiki/page_404.html'}, name='wiki_page_404')

Finally, in my display view function (note that this uses the wiki keyword
defined in the top-level urls.conf to know which :

def display(request, wiki, slug):
    try:
        wiki = models.Wiki.objects.get_or_create(wiki)
        page = models.Page.objects.get(wiki=wiki, slug=slug)
    except models.Page.DoesNotExist:
        url = reverse('%s:wiki_page_404' % wiki.title, kwargs={'slug':
slug}, current_app=wiki.title)
        return HttpResponseRedirect(url)


Thanks,
Brad

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to