python - to access the filter query result passed to templates in django -
i want pass filter query result templates in django. details of each field of row returned presented in form of readable form , every row. using django 1.8
this urls.py
url(r'^pendingregistrations/$',views.pendingapproval, name ='pendingapproval')
this views.py
from django.shortcuts import render_to_response django.http import httpresponse django.template.context_processors import csrf django.views.decorators.csrf import csrf_protect django.core.mail import send_mail django.core import mail fcui.models import * django.db.models import q import urllib django.template import context @csrf_protect def pendingapproval(request): if request.method == 'post' : return httpresponse("post done") elif request.method == 'get' : data = request.get.get('id') decode = urllib.unquote_plus(data) encryptdata import encryption, decryption groupid = decryption(decode) print "group id : " + groupid #else : # userid = request.user_id # query = account_manager_users.objects.get(user_id = userid) # groupid = query.group_id print "group id : " + groupid pending_users_list = pending_user_registrations.objects.filter(group_id = groupid) print pending_users_list c = context({'pending_users_list',pending_users_list}) c.update(csrf(request)) return render_to_response('fcui/pendingregistrations.html',c)
this .html (stored within app folder in templates folder)
{% block content %} <h1 class="page-header">pending user registration details</h1> {% if pending_users_list %} "cmn" {% user_details in pending_users_list %} <form method="post" action = "/appname/pendingregistrations/"> <table> <tr> <td>first name : </td><td><input type = "text" name = "firstname" value = "{{user_details.first_name}}" readonly></input></t$ </tr> <tr> <td>last name : </td><td><input type = "text" name = "lastname" value = "{{user_details.last_name}}" readonly></input></td> </tr> <tr> <td>user name : </td><td><input type = "text" name = "username" value = "{{user_details.user_name}}" readonly></input></td> </tr> <tr> <td>email address : </td><td><input type = "text" name = "emailaddress" value = "{{user_details.email_address}}" readonly></$ </tr> <tr> <td>joining reason : </td><td><input type = "text" name = "reason" value = "{{user_details.joining_reason}}" readonly></inpu$ </tr> </table> <br><br> <input type ="submit" name = "submit" value= "accept" ></input> <input type ="button" value= "reject"></input><br> <input type = "hidden" name = "groupid" value = "{{user_details.group_id}}" readonly></input> {% csrf_token %} </form> <br><br><br> {% endfor %} {% else %} "not cmn" {% endif %}
but screen shows "not cmn" when pending_users_list not empty. why happening ? please help. new django.
edit :
this see on console :
[<pending_user_registraions: priya goel priya29 shubh@gmail.com invited>]
for starters, looks have error on line:
c = context({'pending_users_list',pending_users_list})
where should be:
c = context({'pending_users_list': pending_users_list})
note comma changed colon.
Comments
Post a Comment