I thought you wanted to capture either words or hyphens, so I just
replaced \w, which also consumes underscores, with [a-zA-Z], which
doesn't consume the underscores.  So the new regex

[a-zA-Z-]+

will consume one or more letters or hyphens.  The one I replaced it
with should work for sprint-phone_cellphone.


On Jan 1, 10:36 pm, Greg <[EMAIL PROTECTED]> wrote:
> ocgstyles,
> I'm not sure what's going on.  What does the last '-' mean in the
> following code [a-zA-Z-]?  Occasionally I'm going to have the a url
> that is going to have a '-' in the variable.  For 
> examplehttp://mysite.com/sprint-phone_cellphone.  So I'm not sure if [a-zA-
> Z-] is going to work.
>
> On Jan 1, 8:51 pm, ocgstyles <[EMAIL PROTECTED]> wrote:
>
> > worked for me using the following:
>
> > [urls.py] (i removed the single quotes around the view)
> > from myapp.views import showline
> > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', showline),
>
> > [views.py]
> > def showline(request, manufacturer, line):
> >    return HttpResponse('manu = ' + manufacturer + '<br />line = ' +
> > line)
>
> > Maybe the error is being generated from somewhere else?
>
> > On Jan 1, 9:42 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > ocgstyles,
> > > I tried the following however I'm still getting a page not found
> > > error:
>
> > > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', 'showline'),
>
> > > On Jan 1, 8:23 pm, ocgstyles <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Greg,
>
> > > > The problem is that "\w" is consuming the underscore.  Instead of
> > > > using [\w-], use [a-zA-Z-].  The pattern would then look like:
>
> > > > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', 'showline')
>
> > > > Hope that helps.
>
> > > > Keith
>
> > > > On Jan 1, 9:05 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > > Hello,
> > > > > I orginially had my url like this:
>
> > > > > (r'^(?P<manufacturer>[\w-]+)/(?P<line>[\w-]+)/$', 'showline')
>
> > > > > Which would work fine when going to the url 'www.mysite.com/sprint/
> > > > > cellphone/'
>
> > > > > //////////////
>
> > > > > However, I want to change my url structure so that all of my pages are
> > > > > as close to the root as possible.  So I replaced my '/' in the url
> > > > > with a '_'.  Like so:
>
> > > > > (r'^(?P<manufacturer>[\w-]+)_(?P<line>[\w-]+)/$', 'showline')
>
> > > > > However, I now get a page not found whenever I view the following url
> > > > > 'www.mysite.com/sprint_cellphone/'
>
> > > > > ////////
>
> > > > > Can I not replace the / with a _ in my url?
>
> > > > > Thanks
--~--~---------~--~----~------------~-------~--~----~
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