Hi all, 

I am trying to direct the option selected from the dropdown in the 
index.html along with the value to the process_data method in the views.py. 
But now I am getting the following error when I am trying to load my index 
page: 

NoReverseMatch at /index/

Reverse for 'process_data' not found. 'process_data' is not a valid view 
function or pattern name.




My index.html file is as follows: 

<html lang="en">
<head>
    <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
    <title>Home</title>
</head>
<body>
  <center>
  <h3>Index page</h3>
  <table align='center'>
  <tr><td>Select the version to compare with</td><td>
  <select name="version" id="version" onchange="location = this.value;">
 <option>Select version to compare with</option>
 {%for ver in version_list%}
 <option value={{ver}} href="{% url 'process_data' ver %}">{{ver}}</option>
 {% endfor %}
  </select>
  </td></tr>
  <tr><td>The current version</td><td>{{version}}</td>
  </tr>
  </table>
  <br><br><br>
</body>
</html>

My view file content is like this: 

def index(request):
    #query_results = QRC_DB.objects.all()
    global percentage_variation
    percentage_variation = 0
    global version
    version = None 
    context = RequestContext(request)
    response_context = get_result(request)
    #print("The response_context values  = \n %s" 
%response_context.get("get_result"))
    cursor  = connection.cursor()
    cursor.execute("select version from fusioncharts_qrc_db group by 
version")
    rows = cursor.fetchall()
    #print("The fetched rows =\n")
    #print(rows)
    version_list = []
    #print(version_list)
    for ver in rows:
        version = str(ver).split("'")[1]
        version_list.append(version)

    print("The final version list = %s" %version_list)
    return render(request, 'index.html', {
        'version': version, 
        'version_list': version_list,        
        })


def process_data(request,ver):
    
    print("==============The version selected = %s===========" %ver)

    return render(request, 'display_data.html', {
        'version': version, 
      
        })


The url file contents are as follows: 

from django.urls import path
from fusioncharts import views


urlpatterns = [
    path('push-data/', views.push_data, name='push-data'),
    path('home/', views.home, name='home'),
    path('display_data/<str:component>', views.display_data, name=
'display_data'),
    path('index/', views.index, name='index'),
]

from django.contrib import admin
from django.urls import path,include


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('fusioncharts.urls'))
]

Can anyone please help me why the above error is coming and how to fix that 
? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6b391dfb-f423-4c8f-b713-73c4879ffe34o%40googlegroups.com.

Reply via email to