Good morning
I tryed to use a form to give a variable "x" to my filter... what i have:
startig page Portal-----------------------------------------
{% include "header.html" %}
<title>Kunde</title>
{% include "header2.html" %}
<h1>Kunde</h1>
{% block content %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% 
endblock %}
<form method="post" action="/kundendaten/">
    {% csrf_token %}
        <p>Bitte Kundennamen eingeben</p>
        <label>
            <input type="text" name="kunde" size="30" required="required">
        </label>
        <br>
        <br>
        <input type="submit" name="senden" value="Senden" 
href="kundendaten">

</form>
{% include "footer.html" %}
--------------------------------------------------------------
 
this part run perfect...
at next the page kundendaten will called...
Kundendaten--------------------------------------------
{% include "header.html" %}
<title>Kundendaten</title>
{% include "header2.html" %}
<h1>Portal</h1>
<h2>Ausgabe Kundendaten</h2>
{% block content1 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% 
endblock %}
{% block content2 %}<p>Kundendaten {{ row }}.</p>{% endblock %}
<table border="1">
    <tr>
        <th>Name</th>
        <th>E-Mail</th>
    </tr>
    {% for t_name in row %}
    <tr>
        <td>{{ row.t_name }}</td>
        <td>{{ row.t_mail }}</td>
    </tr>
    {% endfor %}
 

</table>
{% include "footer.html" %}
-------------------------------------------------------
 
there is the problem, that my testlane "{% block content2 %}<p>Kundendaten 
{{ row }}.</p>{% endblock %}" give out correct data (if i give the variable 
x manually), but my table doesent work. it have no data.
next, i give you my views and urls...
 
views-------------------------------------------------
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import csrf_protect
import datetime
import pyodbc
@csrf_protect
def portal(request):
    now = datetime.datetime.now()
    return render_to_response('portal.html', {'current_date': now}, 
context_instance=RequestContext(request))
def kundendaten(request):
    def get_queryset(self):
        kunde = self.request.GET.get("kunde", False)
        if kunde == "all":
            kunde = False
        if kunde:
            variable = kunde
        return get_queryset(variable)
    variable ="x"
    cnxn = pyodbc.connect('DRIVER={SQL 
Server};SERVER=MAURITIUS;DATABASE=baan5c;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 = %r)" %x)
    row = cursor.fetchall()
    now = datetime.datetime.now()
 
    return render_to_response("kundendaten.html", { 'row': 
row,'current_date': now}, context_instance=RequestContext(request))
-------------------------------------------------------------
 
urls--------------------------------------------------------
from django.conf.urls import patterns
from klasse.views import portal, kundendaten
urlpatterns = patterns('',
    (r'^portal/$', portal),
    (r'^kundendaten/$', kundendaten),
)
------------------------------------------------------------
 
thats it, pls can anyone help me to fix the table and the correct code 
using for my variable x, given from page one?
thx for help...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SaJcZ6MGvDkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to