Monday, October 5, 2009

Re: More Reverse Method Woes

Okay, I think I've figured this out with the help of a co-worker and
WOW would I never have gotten this on my own and nobody would have
been able to get it from the code I posted here. It's important
enough to post the problem here.

This problem came out of using the RSS syndication framework in Django
and the differences in how view methods and RSS classes are compiled.

The issue was that I was generating RSS links as follows:

class RssInPlanningReview(SummaryReleaseInfo):
# Feeds for Under Planning Review Queue
title = 'Releases Under Planning Review'
link = reverse('planning-review')
description = 'These Releases are currently awaiting review by
planners.'

Setting the link as an attribute was what was causing the error
because Classes and URL patterns are compiled when the application
loads. So in this case when the application loads it would try to
compile the reverse URL but the URLS haddn't compiled yet. The fix
for this was to move the link into a class method instead of an
attribute so this works fine:

class RssInPlanningReview(SummaryReleaseInfo):
# Feeds for Under Planning Review Queue
title = 'Releases Under Planning Review'
description = 'These Releases are currently awaiting review by
planners.'

def link(self):
return reverse('tech-review')

This is probably obvious to the hard-core programmers here but
something I missed easily and I expect there are others who do as
well.

Thanks to Karen for her help and to my co-worker for his insight.
Hope this post is useful to someone in the future.


On Oct 2, 2:20 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Fri, Oct 2, 2009 at 11:01 AM, Streamweaver <streamwea...@gmail.com>wrote:
>
>
>
>
>
> > I'm continuing to struggle with the reverse method in Django.  After
> > fixing some mistakes of mine earlier I'm getting an
> > ImproperlyConfigured Error whenever I try to use a reverse method.
> > The site works fine with one but whenever I try to use a reverse
> > method, even in shell I get the following error.
>
> > "ImproperlyConfigured: The included urlconf dwrangler.project.urls
> > doesn't have a ny patterns in it"
>
> > [snip]
>
> > **** dwrangler.project.urls file ***
> > urlpatterns = patterns('dwrangler.project.views',
> >    url(r'^list/$', 'project_index', name='list-project'),
> > )
>
> That cannot be the complete file because if it was you would get:
>
> NameError: name 'patterns' is not defined
>
> when it was imported.  What you have shown us is fine.  The problem lies in
> something you have left out.  Something that either makes that entire chunk
> part of a comment, or redefines urlpatterns to be None, or....
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate