Re: urlconf for multiple page slugs

2007-08-10 Thread Peter Baumgartner
>
>
> Collin's suggestion may sound daunting, but it's really quite easy:


Thanks guys. I took your advice. Here is my solution:
http://www.djangosnippets.org/snippets/362/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: urlconf for multiple page slugs

2007-08-10 Thread Tim Chase

> About the only way to do that is just grab (.*) from the url, and
> parse it in your view, looking up slugs as needed


Collin's suggestion may sound daunting, but it's really quite easy:

your urls.py can have something like

r"^(?P(?:[-\w]+/)*[-\w]+)/?$"

and then in your view:

def my_view(request, path):
  # iterate from grandparent -> parent -> child -> grandchild
  for piece in path.split('/'):
do_something(piece)



Not too scary and rather easy to understand (except perhaps for
the regexp, but that's another matter).

-tim




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: urlconf for multiple page slugs

2007-08-10 Thread Collin Grady

About the only way to do that is just grab (.*) from the url, and
parse it in your view, looking up slugs as needed


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



urlconf for multiple page slugs

2007-08-10 Thread Peter Baumgartner
I'm building a site where pages can have parent pages in the form:

* Grandparent 1
* Grandparent 2
** Parent 1
*** Child 1
*** Child 2
** Parent 2

I'd like the url to contain each parent. For example, 'child 2' would be at
/grandparent-2/parent-1/child-2/

I'm not sure how to implement this in my urls.py without hardcoding the
parent slugs. Any ideas?

Here is what my get_absolute_url looks like for each page:

def get_absolute_url(self):
url = "/%s/" % self.slug
page = self
while page.parent:
url = "/%s%s" % (page.parent.slug,url)
page = page.parent
return url

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---