Hi,

If you use something like

r'^(?P<page>.+)/$'

then a variable called page will get passed to your view. It will
contain the string that has been matched against the specified pattern
(in this case any character 1 or more times (.+))

I think django uses standard python regular expressions in its url
mapping.

http://docs.python.org/library/re.html

Your view function might look like this:

def my_view(request, page=None):

Obviously you can default page to be whatever you want.

Regards,

John



On Jul 19, 2:14 pm, Zaheer Soebhan <[email protected]> wrote:
> Maybe make a pattern like r'(home|about|family|aviation|linux|etc)$' to
> match either home, about, family, etc?
> The "|" should work like the "OR"-operator.
>
> 2010/7/19 Ryan Osborn <[email protected]>
>
> > You could try using this as your pattern:
>
> > (?P[a-zA-Z0-9-]+)
>
> > Ryan
>
> > On Jul 19, 1:03 am, Phil Edwards <[email protected]> wrote:
> > > On 18/07/2010 23:55, Phil Edwards wrote:
>
> > > > -----begin-----
> > > > def servePage(request):
> > > > if request.path[1:] == '':
> > > > thisPage = Page.objects.get(name = unicode('home'))
> > > > else:
> > > > thisPage = Page.objects.get(name = unicode(request.path[1:]))
> > > > sidebar_list = Page.objects.filter(category = thisPage.category)
> > > > article_list = Article.objects.filter(page =
> > > > thisPage.id).order_by('-amendedon')
> > > > return render_to_response('base.html', locals())
> > > > ------end------
>
> > > Meh. Don't know what happened to the indentation there, but it should
> > > look like this:
>
> > > -----begin-----
> > > def servePage(request):
> > >      if request.path[1:] == '':
> > >          thisPage = Page.objects.get(name = unicode('home'))
> > >      else:
> > >          thisPage = Page.objects.get(name = unicode(request.path[1:]))
> > >      sidebar_list = Page.objects.filter(category = thisPage.category)
> > >      article_list = Article.objects.filter(page =
> > > thisPage.id).order_by('-amendedon')
> > >      return render_to_response('base.html', locals())
> > > ------end------
>
> > > --
>
> > > Regards
>
> > > Phil Edwards   |  PGP/GnuPG Key Id
> > > Brighton, UK   |  0xDEF32500
>
> > --
> > 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]<django-users%[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