Good morning
i have to many proplems by programing, thats maybe because i am new and my englisch is not the best... (google translator is often a bad tool...)
i tryed to make a page where you can put in a name "kunde" (used as a filter) for the next page...
-----Portal1-----
{% include "header.html" %}
<title>Kunde</title>
{% include "header2.html" %}
<h1>Kunde</h1>
{% include "time.html" %}
<form method="post" action="kundendaten1">
<fieldset>
<legend>Anfrage</legend>
<p>Bitte Kundennamen eingeben</p>
<label>
<input type="text" name="kunde" size="30">
</label>
<br>
<br>
<input type="submit" name="senden" value="Senden">
</fieldset>
</form>
{% include "footer.html" %}
-----
ok, this works... but the action is a bit fail, cause he tell me that he cant find the next page (if you click send)
here is the "kundendaten1"
-----Kundendaten1-----
{% include "header.html" %}
<title>Kundendaten</title>
{% include "header2.html" %}
<h1>Portal</h1>
<h2>Ausgabe Kundendaten</h2>
{% include "time.html" %} #OK, here i tryed my first view
{% include "sql.html" %} #And here the second one... (i know this will not work, but i dont know how i can make 2 includes (views) on one page)
<table border="1">
<tr><th>Name</th><th>E-Mail</th></tr>
<tr><td>'.$result['t_name'].'</td><td>'.$result['t_mail'].'</td></tr> #i tryed it with php, but that won't work... thats why i deleted a part of php
</table>
{% include "footer.html" %}
-----
here my urls and views...:
-----urls-----
from django.conf.urls import patterns, include, url
from klasse.views import portal, kundendaten
urlpatterns = patterns('',
(r'^portal1/$', portal1),
(r'^kundendaten1/$', kundendaten1)
)
-----
-----views-----
from django.shortcuts import render_to_response
import datetime
import pyodbc
def portal1(request):
now = datetime.datetime.now()
return render_to_response('portal1.html', {'current_date': now})
def kundendaten1(request):
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=Severname;DATABASE=Dbname;UID=***;PWD=*****')
cursor = cnxn.cursor()
cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad200000 as x, tttcmf200000 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'kunde')")
#it works when i manually put in a "kunde", i dont know how to put in the sended variable
row = cursor.fetchall()
return render_to_response("kundendaten1.html", { 'row': row })
-----
You see, there are many problems... pls do not post anything like "rtfm" or "ask google" i didnt understood the manuals...
thx for help. :)
i use python 2.7.3
django 1.4.1
pyodbc-3.0.6.win32-py2.7