codyc4321
codyc4321

Reputation: 9682

Django templates not altering form action

I have a URL file chat.urls.py:

`urlpatterns = patterns('',
    url(r'^message/(?P<username>\w+)/$',views.message,name='message'),
    url(r'^message/(?P<username>\w+)/submit/$',views.send_message,name='send_message'),
    url(r'^inbox/$',views.inbox,name='inbox'),
    url(r'^inbox/(?P<username>\w+)/$', views.inbox_by_user,name='inbox_by_user'),
)`

and a message.html template to send a message from with a form like this:

<form action="{% url 'inbox' %}" method="post"> {% csrf_token %} <input type="text" name="text" id="text" value="" /> <label for="message">Enter your message here</label><br />

<input type="submit" value="Send" /> </form>

where I substituted previously working code for "url 'inbox'", and no matter what I substitute for the form action I always get html source rendered as

<form action="/chat/message/[username]/" method="post"...

no matter what. I have restarted the server, made sure I saved changes, and like it has a mind of its own, it's always /chat/message/[username]. When I changed that URL reverse to 'inbox' I should see chat/inbox based on the URLs.

Upvotes: 0

Views: 58

Answers (1)

shellbye
shellbye

Reputation: 4848

According to the information in comment, you need {% url 'chat:inbox' %} not {% url 'inbox' %} in the form.

Upvotes: 1

Related Questions