3

I've already seen the documentation here and I am trying to do the same thing but it is not working. It is not matching the urls.

Here is my urls.py

profile_patterns = patterns('',
    url(r'^profile/$', views.profile),
    url(r'^thoughts/$', views.thoughts),
)

urlpatterns = patterns('',      
    url(r'^/user/(?P<username>\S+)/', include(profile_patterns)),

    # I also tried to do it this way.. But it isn't working.
    url(r'^abc/', include(patterns('', 
        url(r'^hello/$', views.profile)))),

I tried to access the following urls.

'http://<mysite>.com/user/<someUsername>/profile/'
'http://<mysite>.com/abc/hello/'

1 Answer 1

3

try this \w+ instead of \S+ and not '' but the path to user views:

profile_patterns = patterns('userapp.views',
  url(r'^profile/$', profile),
  url(r'^thoughts/$', thoughts),
) 

urlpatterns = patterns('',      
  url(r'^/user/(?P<username>\w+)/', include(profile_patterns)),
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.