Re: problem reversing namespaced URL (application instance not recognized?)

2010-10-17 Thread Brad Buran
Problem solved.  I misunderstood the Django docs on URL namespacing and was
trying to take a shortcut by passing a 3-tuple rather than explicitly naming
the arguments to include.  Instead of include('test.wiki.urls', 'wiki',
'help') I should have been doing include('test.wiki.urls', app_name='wiki',
namespace='help').

Sorry for the trouble,
Brad

On Sun, Oct 17, 2010 at 6:14 PM, Brad Buran  wrote:

> 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[-\w]+)/$', 'test.wiki.views.display',
> name='wiki_page_detail'),
> url(r'^(?P[-\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.



problem reversing namespaced URL (application instance not recognized?)

2010-10-17 Thread Brad Buran
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[-\w]+)/$', 'test.wiki.views.display',
name='wiki_page_detail'),
url(r'^(?P[-\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.