more problems than one

15 views
Skip to first unread message

Nebros

unread,
Nov 9, 2012, 4:13:23 AM11/9/12
to django...@googlegroups.com
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)
Request URL:http://127.0.0.1:8000/portal/kundendaten1 page not found...
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

Sergiy Khohlov

unread,
Nov 9, 2012, 5:05:26 AM11/9/12
to django...@googlegroups.com
add the /  at the end of your page

2012/11/9 Nebros <markusch...@gmail.com>

--
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/-/Bp-is7zodugJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Nebros

unread,
Nov 9, 2012, 5:14:11 AM11/9/12
to django...@googlegroups.com
hmm? there is more than just one page... what do you mean tochange, and what does it make?

Nebros

unread,
Nov 9, 2012, 5:16:09 AM11/9/12
to django...@googlegroups.com
 And there are mor problems in the code... i marked it with:
#and the problem i have there...

Sergiy Khohlov

unread,
Nov 9, 2012, 6:21:46 AM11/9/12
to django...@googlegroups.com
Take a look at your urls.py

from django.conf.urls import patterns, include, url
from klasse.views import portal, kundendaten
urlpatterns = patterns('',
(r'^portal1/$', portal1),
(r'^kundendaten1/$', kundendaten1)
)

this means next :
next urls are served :
portal1/<something or empty >
and kundendaten1/<something or empty>


Take a look at https://docs.djangoproject.com/en/dev/topics/http/urls/


Also if it you would like to serve ^kundendaten1 try to add next line :

(r'^kundendaten1', kundendaten1)



2012/11/9 Nebros <markuschri te...@gmail.com>:
> And there are mor problems in the code... i marked it with:
> #and the problem i have there...
>
> --
> 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/-/zCCvQ1J8NaUJ.

Nebros

unread,
Nov 9, 2012, 8:37:22 AM11/9/12
to django...@googlegroups.com
ok, that was not really useful for me... :( 
Reply all
Reply to author
Forward
0 new messages