简体   繁体   中英

How to jump from 'form action' to view in pycharm

I used PyCharm to write Django code. I write a form in a HTML file.

   <form class="form-horizontal" action="query" method="post">
        <div class="form-group">
            <div class="input-group">
                <input type="text" name="key_word" class="form-control" placeholder="查询条件">

                <div class="input-group-btn">
                    <button type="submit" class="btn btn-primary btn-bg-red">
                        查询
                    </button>
                </div>
            </div>
        </div>
    </form>

The action of the form is 'query'. And my urls.py is

url(r'^query/$', query.key_word_query, name='index')

But PyCharm throws an exception "Cannot resolve file 'query'" and "This inspection checks unresolved file references in HTML. ".
Why?
And could PyCharm jump to the matched view (query.key_word_query) by clicking the action 'query'?

Your url contains a / ( query/ ) whereas your action doesn't. So you could remove this slash but this isn't really the correct fix, you should be using the url template tag.

<form class="form-horizontal" action="{% url 'index' %}" method="post">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM