Holy cow you're right.  That was an extreme case of needing another pair of
eyes.  I thought I had tested the view after using that syntax, but I must
not have tested the right scenario.

Many thanks. I will check it out in the morning :)

Tim

Sent from my iPod; pardon any typos and poor grammar!

On Nov 24, 2009, at 10:33 PM, Karen Tracey <[email protected]> wrote:

On Tue, Nov 24, 2009 at 11:20 PM, Tim Valenta <[email protected]>wrote:

> Thanks for the reply.  Yes, I can give a bit more info on it.
>
> So, for starters, my (abbreviated) main url conf looks like this:
>
>    urlpatterns = patterns('',
>        (r'^surveys/', include('servicetrac.surveys.urls')),
>    )
>
> ... which links over to the app's urls:
>
>    urlpatterns = patterns('servicetrac.surveys.views',
>        (r'^(?P<company_slug>[^/]+)/(?P<event_id>\d+)/web/take/(?
> P<page>\d+)', 'take_survey', {
>            'name': 'this_is_a_name',
>        }),
>

>From what you have below it sounds like you are intending to name this url
pattern 'this_is_a_name'.  But that is not what you have done here --
rather, you are passing an additional keyword parameter, name, with value
'this_is_a_name', to your take_survey view.  (Which is going to cause an
error an any use of this pattern, since your view isn't expecting that
keyword parameter.)

To name this pattern, you would either do:

      (r'^(?P<company_slug>[^/]+)/(?P<event_id>\d+)/web/take/(?P<page>\d+)',
'take_survey', {}, 'this_is_a_name'),

That is, specify the name as the 4th item in the tuple -- you must include
an empty optional dictionary as the 3rd item since there is no way to
specify a 4th item without a 3rd using the tuple format.  Or use the url
function, and specify the name keyword argument to it:


url(r'^(?P<company_slug>[^/]+)/(?P<event_id>\d+)/web/take/(?P<page>\d+)',
'take_survey'. name='this_is_a_name'),



>        (r'^(?P<company_slug>[^/]+)/(?P<event_id>\d+)/web/take',
> 'take_survey', {'page': 1}),
>    )
>
> And the "take_survey" view signature:
>
>    take_survey(request, company_slug, event_id, page=1)
>
> The default parameter for 'page' is a little redundant to what the
> urls define, but it's self-documenting, in my mind.
>
> So, up to this point, everything works as expected.  Absolutely no
> problems.  The view works great, tested under both of the possible
> urls to get there.  But of course, I wanted to partake of the niceness
> of having a "View on site ->" link on the admin page for the object,
> so I began to implement the "get_absolute_url" method, employing the
> decorator "models.permalink", as described previously:
>
>    # in my "Event" model
>    @models.permalink
>    def get_absolute_url(self):
>        return ('this_is_a_name', (), {
>            'company_slug': self.company.slug
>            'event_id': self.id
>            'page': 1
>        })
>
>
>
Once you get the naming working, I'd expect this to work,assuming you have
commas on the end of a couple of those lines.  Alternatively, don't use the
name but rather specify 'servicetrac.surveys.views.take_survey' -- that is
the full name, including prefix from the patterns() call.

Karen

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

--

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


Reply via email to