Cannot make url with query strings in django template: Here is example:
<a href="{% url getFormMetaData %}?code=RHJ6YXZh">Form</a>
and urls.py file looks like this:
url(r'^main/getFormMetaData/$', views.getFormMetaData, name='getFormMetaData'),
Cannot make url with query strings in django template: Here is example:
<a href="{% url getFormMetaData %}?code=RHJ6YXZh">Form</a>
and urls.py file looks like this:
url(r'^main/getFormMetaData/$', views.getFormMetaData, name='getFormMetaData'),
You need to put single quotes around getFormMetaData. Not using quotes was acceptable in previous version of Django, but that has now been deprecated.
Thus, your code should be:
<a href="{% url 'getFormMetaData' %}?code=RHJ6YXZh">Form</a>
Reference: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
views.py then views.getFormMetaData is correct. But, if it's contained in a file that is within a views directory then you will need to say views.some_filename.getFormMetaData.request that is passed in. Thus, your view should read: def getFormMetaData(request):. If there are more arguments to the function then you must pass that as a parameter in the URL template call.I must answer my own question...
Something really not good here...
in that urls.py file i have something like this:
url(r'^main/$', views.main, name='main'),
url(r'^main/getFormMetaData/$', views.getFormMetaData, name='getFormMetaData'),
These url tags i have in main.html. I can access to main.html like this:
http://localhost:9000/TestProjekat/main/
Now, how to pass an one or two arguments in getFormMetaData from main.html.. How to wrote url tags?
{% url 'namedURL' v1 v2 %}. Alternatively, you may name the arguments: {% url 'namedURL' arg1=v1 arg2=v2 %}.