1

I have a working django project. I wrote a small app - pm - and I tried to include its urls.py in the active project:

urlpatterns = patterns('',
    # ... some urls here
    url(r'^$', views.home, name='vw_home'),
    # I added the following line:
    (r'^pm/', include('pm.urls')),

Once I access the main web page, I receive the following error:

TemplateSyntaxError at /
Caught error while rendering: syntax error

and the debug shows the problem in the following line:

<a href="{% url vw_home %}">Home</a>

If I remove the last url pattern (the include()), the page renders without any problem.
How can this be fixed?

EDIT:
Adding the urls.py of the pm app:

from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns("pm.views",
    url(r'^inbox/$', 'inbox', {'folder': 'inbox'}, name='vw_inbox'),
    url(r'^sent/$', 'inbox', {'folder': 'sent'}, name='vw_sent'),
    url(r'^message/(?<message_id>\w+)/$', 'read_message', name='vw_read_message'),
    url(r'^compose/(?P<profile_id>\w+)/$', 'compose_message', name='vw_compose_message'),
    url(r'^reply/(?P<message_id>\w+)/$', 'compose_message', name='vw_reply_message'),
)
user1102018
  • 4,369
  • 6
  • 26
  • 33

1 Answers1

0
url(r'^message/(?<message_id>\w+)/$', 'read_message', name='vw_read_message'),

You missed ?P

San4ez
  • 8,091
  • 4
  • 41
  • 62
  • Thanks, I did miss the P. While this didn't solve the error, I found the source of the problem, which was a line in the pm/views.py file. I don't know why Django indicated that the problem was in the template of the main project. Thanks everyone – user1102018 Mar 29 '12 at 20:35
  • Anyway django couldn't compile regexp patterns with this misspell when you included patterns from `pm.urls`. Line in the `pm/views.py` was the second one. – San4ez Mar 29 '12 at 20:43
  • 1
    Why does Django indicates in templates? Because Django loads modules lazily when you access them. If you imported `view` using `from pm.views import read_message` you would get error earlier. – San4ez Mar 29 '12 at 20:53