1

In my urls.py file, I have

urlpatterns = patterns('',
                       (r'^$',home_page),
                       #(r'^'+main_cagetory_url_string+'$','home_page'),
                       (r'^(?:cam_sanh|buoi_da_xanh|cam_da_xanh)$','home_page'),
                       (r'^admin/', include(admin.site.urls)),)

I want to use that pattern to access cam_sanh, buoi_da_xanh, cam_da_xanh page. But I receive error:

'str' object is not callable

How can I fix this bug?

2 Answers 2

4

Django will attempt to lookup the view using the string you provide, however, you need to specify the full view path, aka, 'my_project.view_name'

Alternatively, you can do as Filip suggested and give it the view name as the callback but then you need to import the view into your urls.py file.

Sign up to request clarification or add additional context in comments.

Comments

2

For this line specifically, (r'^(?:cam_sanh|buoi_da_xanh|cam_da_xanh)$','home_page'),, the second tuple element should be a callback function, not a string.

This should fix it:

urlpatterns = patterns('',
    (r'^$',home_page),
    (r'^(?:cam_sanh|buoi_da_xanh|cam_da_xanh)$',home_page),
    (r'^admin/', include(admin.site.urls)),
)

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.