0

I have a django project that is connected to SQL server database and when i 
tried to click button to retrieve data from the database the system crash .

i am trying to convert the below syntax in ORM into raw sql:

dbEntry = Person_.objects.get(pk =pk) 

Note : *I am not using ORM*

once i tried to perform the task the system crash and display:

getEvents() got unexpected keyword argument "id"

urls.py

path("events/<int:id>/",getEvents,name = "getEvents"),

views.py

def getEvents(request,pid):
  q1 = cuesor.execute("Select Person_.ID FROM Person_ WHERE ID = pid")
  print("q1=",q1)
  qresult = q1.fetchone()
  print("qresult",qresult)
  return render(request,"connect.html",{"qresult":qresult})

list.html

<form method = "GET" action = "{% url 'getEvents' obj.0 %}"# obj is the 
iterator --- 0 is the first field in the table == ID
   <button class = "btn btn-primary">get details</button></form>

display.html

{% for row in qresult %}
  <p> {{ row.0 }} </p>{% endfor %}

-- 
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/12fcc5c9-960d-4690-b479-bcbddb04ea99%40googlegroups.com.

Reply via email to