Re: pyodbc utf-8
It was not possible to find a way by myself. thats maybe cause im new in python / django. i know there is one who can helps... it will be very friendly for a usable response. :) Am Dienstag, 27. November 2012 09:49:37 UTC+1 schrieb Nebros: > Hello community > > i have a next problem. i have connected with pyodbc to a mssql db. i read > values out of it, all works, but i have problems with "ä" "ö" and "ü". > on my html.page i made this into the header: > > > > on all my pages this umlauts works, but not the values of the pyodbc... > when i only give out the row, i become something like this: Hansj\xf6rg > ,but it have to be this: Hansjörg > when i print this value out into a table, the field keeps empty. > > it must be a problem of pyodbc, but i dont know how to fix it. i tryed > something like this: > > views.py > def kundendaten(request): > ret = request.POST > form = ret['kunde'] > conn = pyodbc.connect('DRIVER={SQL > Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader') > cursor = conn.cursor() > cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 > as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = > '%s')"%form) > rows = unicode(cursor.fetchall(), 'utf-8') > now = datetime.datetime.now() > return render_to_response("kundendaten.html", { 'rows': rows, > 'current_date': now, 'form': form}, > context_instance=RequestContext(request)) > - > but the page gave this error: > TypeError at /kundendaten/ > > coercing to Unicode: need string or buffer, list found > > > i dont know how i can fix my problem... what i use: > win7 32bit > python 2.7 > django 1.4.1 > pyodbc 3.0.6 > > can someone halp me to fix this problem? > -- 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/-/lVFpWJlTT-MJ. 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.
Re: pyodbc utf-8
I use win7 32bit... dont know what you need to know aswell. ^^ Am Montag, 3. Dezember 2012 11:01:53 UTC+1 schrieb Nebros: > Can that be, that my computer have the problem and not python itself? > > -- 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/-/2aVh5Hm416YJ. 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.
Re: pyodbc utf-8
Can that be, that my computer have the problem and not python itself? Am Dienstag, 27. November 2012 09:49:37 UTC+1 schrieb Nebros: > Hello community > > i have a next problem. i have connected with pyodbc to a mssql db. i read > values out of it, all works, but i have problems with "ä" "ö" and "ü". > on my html.page i made this into the header: > > > > on all my pages this umlauts works, but not the values of the pyodbc... > when i only give out the row, i become something like this: Hansj\xf6rg > ,but it have to be this: Hansjörg > when i print this value out into a table, the field keeps empty. > > it must be a problem of pyodbc, but i dont know how to fix it. i tryed > something like this: > > views.py > def kundendaten(request): > ret = request.POST > form = ret['kunde'] > conn = pyodbc.connect('DRIVER={SQL > Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader') > cursor = conn.cursor() > cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 > as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = > '%s')"%form) > rows = unicode(cursor.fetchall(), 'utf-8') > now = datetime.datetime.now() > return render_to_response("kundendaten.html", { 'rows': rows, > 'current_date': now, 'form': form}, > context_instance=RequestContext(request)) > - > but the page gave this error: > TypeError at /kundendaten/ > > coercing to Unicode: need string or buffer, list found > > > i dont know how i can fix my problem... what i use: > win7 32bit > python 2.7 > django 1.4.1 > pyodbc 3.0.6 > > can someone halp me to fix this problem? > -- 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/-/S8otKqKqLccJ. 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.
Re: pyodbc utf-8
Ich habe einen Holzweg beschritten und ich werde ihn auch zu Ende gehen... :) I have taken a wrong path and I will follow it through to the end ... :) Am Donnerstag, 29. November 2012 07:53:18 UTC+1 schrieb Nebros: > Its compatible with mysql, but it's not working with mssql. it gave only > errors with the correct settings... thats why i have to make own settings > for the odbc. > > > Am Mittwoch, 28. November 2012 14:30:57 UTC+1 schrieb Daniel Roseman: > >> On Wednesday, 28 November 2012 13:17:39 UTC, Nebros wrote: >> >>> edit: in the db the values are correct and i cant change there >>> something... >>> >> >> Meanwhile we still don't know why you won't use Django's proper ORM >> functionality, which is perfectly compatible with MSSQL and ODBC. >> -- >> DR. >> > -- 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/-/C8nNqF1x3O8J. 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.
Re: pyodbc utf-8
Its compatible with mysql, but it's not working with mssql. it gave only errors with the correct settings... thats why i have to make own settings for the odbc. Am Mittwoch, 28. November 2012 14:30:57 UTC+1 schrieb Daniel Roseman: > On Wednesday, 28 November 2012 13:17:39 UTC, Nebros wrote: > >> edit: in the db the values are correct and i cant change there >> something... >> > > Meanwhile we still don't know why you won't use Django's proper ORM > functionality, which is perfectly compatible with MSSQL and ODBC. > -- > DR. > -- 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/-/s24nmXkEg58J. 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.
Re: pyodbc utf-8
edit: in the db the values are correct and i cant change there something... -- 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/-/D5pcYfIMUqEJ. 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.
pyodbc utf-8
Hello community i have a next problem. i have connected with pyodbc to a mssql db. i read values out of it, all works, but i have problems with "ä" "ö" and "ü". on my html.page i made this into the header: on all my pages this umlauts works, but not the values of the pyodbc... when i only give out the row, i become something like this: Hansj\xf6rg ,but it have to be this: Hansjörg when i print this value out into a table, the field keeps empty. it must be a problem of pyodbc, but i dont know how to fix it. i tryed something like this: views.py def kundendaten(request): ret = request.POST form = ret['kunde'] conn = pyodbc.connect('DRIVER={SQL Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader') cursor = conn.cursor() cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = '%s')"%form) rows = unicode(cursor.fetchall(), 'utf-8') now = datetime.datetime.now() return render_to_response("kundendaten.html", { 'rows': rows, 'current_date': now, 'form': form}, context_instance=RequestContext(request)) - but the page gave this error: TypeError at /kundendaten/ coercing to Unicode: need string or buffer, list found i dont know how i can fix my problem... what i use: win7 32bit python 2.7 django 1.4.1 pyodbc 3.0.6 can someone halp me to fix this problem? -- 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/-/mu-OphC5QjcJ. 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.
Re: row = cursor.fetchone() / row = cursor.fetchall()
I found the answer by myself... it was just to add this: ret = request.POST form = ret['kunde'] and use this "form" as a variable... "%s" %form Am Freitag, 23. November 2012 08:31:30 UTC+1 schrieb Nebros: > I saw your answer and it was long and with a lot of time, i thanks for > that. I have removed {% block content %} and i did other changes, like you > sayed. > > >>> c.execute("SELECT id, name from auth_group WHERE id < 4") > 3L > >>> c.fetchall() > ((2L, u'Client Super User'), (3L, u'Helpdesk User'), (1L, u'IT User')) > > ^ > | > | This part i didnt understand what you mean, but doesent matter. :) > > And: > {% for row in rows %} > > {{ row.0 }} > {{ row.1 }} > > {% endfor %} > > ^ > | > | This part was, what i have searched for. I am very new in Python/Django > and what I can do is yust copy/paste and understand what I have copied, but > I cant really create my own code atm. > > It works now, and I am really happy about that. :) > Now there is only one problem left, how can i use my value out of my form > and use it as a variable? ^^ > > Thank you very much Tom, you was very helpful. =) > -- 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/-/SfoHaLt6cS8J. 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.
Re: row = cursor.fetchone() / row = cursor.fetchall()
I saw your answer and it was long and with a lot of time, i thanks for that. I have removed {% block content %} and i did other changes, like you sayed. >>> c.execute("SELECT id, name from auth_group WHERE id < 4") 3L >>> c.fetchall() ((2L, u'Client Super User'), (3L, u'Helpdesk User'), (1L, u'IT User')) ^ | | This part i didnt understand what you mean, but doesent matter. :) And: {% for row in rows %} {{ row.0 }} {{ row.1 }} {% endfor %} ^ | | This part was, what i have searched for. I am very new in Python/Django and what I can do is yust copy/paste and understand what I have copied, but I cant really create my own code atm. It works now, and I am really happy about that. :) Now there is only one problem left, how can i use my value out of my form and use it as a variable? ^^ Thank you very much Tom, you was very helpful. =) -- 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/-/GVP7G20UOuMJ. 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.
Re: row = cursor.fetchone() / row = cursor.fetchall()
EDIT: with fetchall the output is a table with a lot of empty lines. just with fetchone the lines are diffrent in count. fetchone: so many filled lines like variables ( name, mail, user,...) fetchall: so many empty lines like values like diffrent users there are... Am Donnerstag, 22. November 2012 15:27:34 UTC+1 schrieb Nebros: > Hello, i know I have asked this before in another post of me, but no one > answered on it and it was not part of topic... > > I am using pyodbc and try to give data out into my page... > > Here the part of pyodbc (and yes this works): > > views- > . > 1conn = pyodbc.connect('DRIVER={SQL > Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*') > 2 cursor = conn.cursor() > 3cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, > tttcmf20 as y WHERE (x.t_name = y.t_name)") > 4row = cursor.fetchall() > 5 > 6return render_to_response("kundendaten.html", { 'row': row}, > context_instance=RequestContext(request)) > . > - > > On line number 4 you can see now, there is "row = cursor.fetchall()"... > When i give out this part now i become two outputs, (one without formatting > to see what value i become, the other have to be in a table) > > Here the parts of my website: > > Kundendaten- > . > {% block content2 %}Kundendaten{{ row }}.{% endblock %} > . > > Name > Mail > > {% for t_user in row %} > > {{ row.t_name }} > {{ row.t_mail }} > > {% endfor %} > . > -- > > 1.: > [('Ackermann Marcel (THA) ', 'marcel.ackermann@***.ch '), ('Adami Renate > (HEI) ', 'renate.adami@*.ch '), ('Ammann Cornelia (HEI) ', > 'cornelia.ammann@*.ch '), ('Ausbildung A. Schwaller (HEI) ', > 'giulia.franco@*.ch '), ('General_User_NT (SYS) ', 'baan-alarm@*.ch '), > ('Benz Roger (THA) ', 'roger.benz@*.ch '), . > > 2.: > (A table with only name and mail as colum titles and but 2 empty lines) > > When i add now on line 3 by views t_user like this: > 3 cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 > as x, tttcmf20 as y WHERE (x.t_name = y.t_name)") > I become a longer output... and a table with 3 empty lines > > When i use it now with fetchone and two selects: > 4 row = cursor.fetchone() > I become a table like this: > > NameMailAckermann Marcel (THA) marcel.ackermann@***.ch Ackermann Marcel > (THA) > > marcel.ackermann@***.ch > And with tree selects there will be tree lines with same value... > > Now my question: > How can i make my output correct with fetchall that i can see all lines > with the correct values? > -- 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/-/6qL3ukInrN8J. 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.
row = cursor.fetchone() / row = cursor.fetchall()
Hello, i know I have asked this before in another post of me, but no one answered on it and it was not part of topic... I am using pyodbc and try to give data out into my page... Here the part of pyodbc (and yes this works): views- . 1conn = pyodbc.connect('DRIVER={SQL Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*') 2 cursor = conn.cursor() 3cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name)") 4row = cursor.fetchall() 5 6return render_to_response("kundendaten.html", { 'row': row}, context_instance=RequestContext(request)) . - On line number 4 you can see now, there is "row = cursor.fetchall()"... When i give out this part now i become two outputs, (one without formatting to see what value i become, the other have to be in a table) Here the parts of my website: Kundendaten- . {% block content2 %}Kundendaten{{ row }}.{% endblock %} . Name Mail {% for t_user in row %} {{ row.t_name }} {{ row.t_mail }} {% endfor %} . -- 1.: [('Ackermann Marcel (THA) ', 'marcel.ackermann@***.ch '), ('Adami Renate (HEI) ', 'renate.adami@*.ch '), ('Ammann Cornelia (HEI) ', 'cornelia.ammann@*.ch '), ('Ausbildung A. Schwaller (HEI) ', 'giulia.franco@*.ch '), ('General_User_NT (SYS) ', 'baan-alarm@*.ch '), ('Benz Roger (THA) ', 'roger.benz@*.ch '), . 2.: (A table with only name and mail as colum titles and but 2 empty lines) When i add now on line 3 by views t_user like this: 3 cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name)") I become a longer output... and a table with 3 empty lines When i use it now with fetchone and two selects: 4 row = cursor.fetchone() I become a table like this: NameMailAckermann Marcel (THA) marcel.ackermann@***.ch Ackermann Marcel (THA) marcel.ackermann@***.ch And with tree selects there will be tree lines with same value... Now my question: How can i make my output correct with fetchall that i can see all lines with the correct values? -- 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/-/kKaTFk-9_TkJ. 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.
Re: how to use get_queryset in my code
yes, i copied all data in the correct folder, but it didnt work. but thats not more my problem... i changed row = cursor.fetchall() into row = cursor.fetchone() this give me out the correct data into the correct column of my table. my next problem there is, why it doesent work with fetchall or fatchmany, and why he give me out something like this: Open Orders BAANNameE-MailAckermann Marcel (THA) marcel.ackermann@***.ch Ackermann Marcel (THA) marcel.ackermann@***.ch i mean, why it give me out 2 times the same...? to use my formular data as a filter is another and maybe the biger problem... Am Mittwoch, 21. November 2012 12:02:10 UTC+1 schrieb ?manu*: > On Wednesday, November 21, 2012 7:53:59 AM UTC+1, Nebros wrote: > >> Its not a problem of the version, my pycharm gave no error, but it was >> not possible to generate the model... by generating there was always an >> error, like it cant find an class or something else >> > > Are you sure the problem is on the db API and not in your code? > -- 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/-/zFSPmx6fFE0J. 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.
Re: how to use get_queryset in my code
Its not a problem of the version, my pycharm gave no error, but it was not possible to generate the model... by generating there was always an error, like it cant find an class or something else. Am Dienstag, 20. November 2012 19:35:36 UTC+1 schrieb Martin J. Laubach: > I tryed first this part with db models. but mssql doesnt work on it... >> > > BTW, why? I see there's a django-mssql, that should allow you to connect > to the database. Doesn't it work with your version? I've never tried it > though, I just googled around a bit... > > > -- 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/-/ywIaA4jUvRwJ. 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.
Re: how to use get_queryset in my code
I tryed first this part with db models. but mssql doesnt work on it... i cant generate the model by themself. thats why i made it by my own. in addition, the next part of my program is to implements lotus notes db... i can do it on the same way, thats why i try to do this. And yes, i create my own, but its not like php. :) so pls just help me by this problem, cause i do not know everything about programming with django. Am Dienstag, 20. November 2012 14:39:07 UTC+1 schrieb Martin J. Laubach: > Okay. You seem to be rather confused about the django approach to things > I'm afraid. > > (a) You use raw sql instead of django's ORM mapper. That's okayish, but > then you're on your own for building your queries and have to manually do > validation and escaping and whatnot, which is, as you noticed, a pain in > the behind. > > (b) You chose to manually build and parse the form. That's okayish, but > then you're on your own validating user input. > > I strongly suggest you read up on django models ( > https://docs.djangoproject.com/en/1.4/topics/db/models/) and django forms > (https://docs.djangoproject.com/en/1.4/topics/forms/), which will do most > of what you want without you reimplementing everything from scratch. What > you've shown looks more like some converted php code than a native django > application. > > -- 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/-/GgVsgJdB--oJ. 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.
Re: how to use get_queryset in my code
Ok, what is my task... I have my first page called "Portal". i can give there in a variable, and can send the value with this form to the next page. I tryed now to use this value as a variable you can see here: AND (x.t_user = %r)" %x this %x have to be my value of page one, i have given. I know this code: 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 tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = %r)" %x) row = cursor.fetchall() give me out data like this: [('Ackermann Marcel (THA) ', ***@***.ch '), ('Adami Renate (HEI) ', ***@***.ch '), ('Ammann Cornelia (HEI) ', '***@***.ch '), ('Ausbildung A. Schwaller (HEI) ', '***@***.ch '), And now the two questtions: 1. How can i set my value of the form as the variable %x? and 2. How can i give out my data as a table to my page "Kundendaten"? Ignore my fails like: --- def kundendaten(request): def get_queryset(self): kunde = self.request.GET.get("kunde", False) -- i was trying something, cause i dont know how... ^^ Am Dienstag, 20. November 2012 11:10:06 UTC+1 schrieb Daniel Roseman: > On Tuesday, 20 November 2012 07:25:55 UTC, Nebros wrote: > >> I can really need your help, i don't have found the solution till now. :( >> > > You've had no replies because no-one can understand what you're asking. > Something about querysets, but you seem to be using raw SQL in your > code, for no apparent reason. And your code is totally unclear: what is > that nested function doing, and why does it refer to `self`? And why is it > calling itself? > > Please post a *minimal* example that shows the problem, and describe > exactly what you want to achieve and exactly what is going wrong, including > any errors you receive. > -- > DR. > -- 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/-/yUGGDY4NWOAJ. 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.
Re: how to use get_queryset in my code
I can really need your help, i don't have found the solution till now. :( -- 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/-/l397ya2KOJgJ. 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.
Re: how to use get_queryset in my code
It will be very helpful, if anyone can help me. I need it for my work and I cant find the solution... :( -- 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/-/GVk5kESQhN4J. 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.
how to use get_queryset in my code
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" %} Kunde {% include "header2.html" %} Kunde {% block content %}Zeit der Aktualisierung {{ current_date }}{% endblock %} {% csrf_token %} Bitte Kundennamen eingeben {% include "footer.html" %} -- this part run perfect... at next the page kundendaten will called... Kundendaten {% include "header.html" %} Kundendaten {% include "header2.html" %} Portal Ausgabe Kundendaten {% block content1 %}Zeit der Aktualisierung {{ current_date }}{% endblock %} {% block content2 %}Kundendaten {{ row }}.{% endblock %} Name E-Mail {% for t_name in row %} {{ row.t_name }} {{ row.t_mail }} {% endfor %} {% include "footer.html" %} --- there is the problem, that my testlane "{% block content2 %}Kundendaten {{ row }}.{% 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 tttaad20 as x, tttcmf20 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.
Post in view
Hi again. I tryed to use my "POST" from the site before as a variable of the view from page 2. Here you can see my 2 pages and the views...: page one "portal.html" {% include "header.html" %} Kunde {% include "header2.html" %} Kunde {% block content %}Zeit der Aktualisierung {{ current_date }}{% endblock %} {% csrf_token %} Bitte Kundennamen eingeben page 2 "kundendaten.html" {% include "header.html" %} Kundendaten {% include "header2.html" %} Portal Ausgabe Kundendaten {% block content1 %}Zeit der Aktualisierung {{ current_date }}{% endblock %} {% block content2 %}Kundendaten {{ row }}.{% endblock %} NameE-Mail {% include "footer.html" %} -- views.py--- 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): cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=MAURITIUS;DATABASE=***;UID=portal;PWD=*') cursor = cnxn.cursor() cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'HERE')") row = cursor.fetchall() now = datetime.datetime.now() return render_to_response("kundendaten.html", { 'row': row,'current_date': now}, context_instance=RequestContext(request)) -- you can see in my views this (x.t_user = 'HERE')... this "HERE" must be a variable, the value have to be this POST from page one. can anyone help me 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/-/N42xRanxSb4J. 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.
Re: views on one page
That was exactly what i have searched for. thank you very mutch. it works now. i post here again my current code, if another needs the same help... views- def kundendaten(request): 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 tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'niedereh')") row = cursor.fetchall() now = datetime.datetime.now() return render_to_response("kundendaten.html", { 'row': row,'current_date': now }, context_instance=RequestContext(request)) and here a part of my kundendaten.html kundendaten-- Ausgabe Kundendaten {% block content1 %}Zeit der Aktualisierung {{ current_date }}{% endblock %} {% block content2 %}Kundendaten {{ row }}.{% endblock %} have a nice day! :) Am Freitag, 16. November 2012 04:14:17 UTC+1 schrieb Vibhu Rishi: > I don't think you can use 2 views on the same page. > > what you can do is pass 2 values to the same page to display. > > so in the 2nd view you will do as follows: > return render_to_response("kundendaten.html", { 'row': row,'current_date': > now }, context_instance=RequestContext(request)) > > and make sure that you have a variable for now in the 2nd view. > > Hope this helps. > > V. > > > On Thu, Nov 15, 2012 at 2:33 PM, Nebros <markusch...@gmail.com > > wrote: > >> Are there not more intput? pls help me, I do not go any further...! >> >> Am Mittwoch, 14. November 2012 10:50:04 UTC+1 schrieb Nebros: >> >>> Good morning >>> I have 2 diffrent views, every one i just needet on one page... till now. >>> >>> view one-output is the time- >>> @csrf_protect >>> def portal(request): >>> now = datetime.datetime.now() >>> return render_to_response('portal.**html', {'current_date': now}, >>> context_instance=**RequestContext(request)) >>> --**--- >>> >>> view two-output are data out of a mssql db-- >>> def kundendaten(request): >>> 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 tttaad20 as x, >>> tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'niedereh')") >>> row = cursor.fetchall() >>> return render_to_response("**kundendaten.html", { 'row': row }, >>> context_instance=**RequestContext(request)) >>> --**--** >>> --- >>> >>> in addition, i have to set the x.t_user as a variable. the value will be >>> given from the page before. (form/post/submit) >>> >>> how can i use this two now on one page? (i know these are two >>> render_to_response and i cant just use: >>> {% block content %}Zeit der Aktualisierung {{ current_date }}{% >>> endblock %} >>> and >>> {% block content %}Kundendaten {{ row }}.{% endblock %} >>> on one page)... >>> >>> I just failed by the try to change them... >>> >> -- >> 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/-/Fxv5JtTBvnAJ. >> >> 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. >> > > > > -- > Simplicity is the ultimate sophistication. - Leonardo da Vinci > Life is really simple, but we insist on making it complicated. - Confucius > -- 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/-/mjiukqQ-K5UJ. 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.
Re: from odbc to table
I have tryed this way before, but it doesent work. it has many fails in the code... one of these are: "AttributeError: 'Settings' object has no attribute 'DATABASE_COLLATE'" thats why i searched another way... if you can help me to make this run, i will use this. but i asked many times for that and no one gave answer... ^^ Am Donnerstag, 15. November 2012 11:50:19 UTC+1 schrieb Tom Evans: > On Thu, Nov 15, 2012 at 9:02 AM, Nebros <markusch...@gmail.com> > wrote: > > good morning. > > i have an odbc connect to a mssql db... it works and it looks like this: > > views--- > > def kundendaten(request): > > 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 tttaad20 as x, > > tttcmf20 as y WHERE (x.t_name = y.t_name)") > > row = cursor.fetchall() > > return render_to_response("kundendaten.html", { 'row': row }, > > context_instance=RequestContext(request)) > > --- > > > > what does it do? it gives out the name and the e-mail of a customer. the > > values are from two tables together and with "WHERE (x.t_name = > y.t_name)" i > > avoid redundancy. > > > > here the output of these request: > > --- > > [('Ackermann Marcel (THA) ', 'marcel.***@***.ch '), ('Adami Renate (HEI) > ', > > 'renate.***@***.ch '), ('Ammann Cornelia (HEI) ', 'cornelia.***@***.ch > '), > > ('Ausbildung A. Schwaller (HEI) ', 'giulia.***@***.ch '), > ('General_User_NT > > (SYS) ', 'baan-alarm@***.ch '), ('Benz Roger (THA) ', 'roger.***@***.ch > '), > > ('Berktold Stefan (THA) ', 'stefan.***@***.ch '), ('Biegger Christian > (THA) > > ')] > > --- > > > > and now my problem... i dont know how that i can give it out into a > table. i > > createt a modul: > > modul--- > > from django.db import models > > class Person(models.Model): > > t_name = models.CharField(max_length=30) > > t_mail = models.CharField(max_length=30) > > > > > > i dont know whether i need this and i dont know how to use the table, > that > > it works... > > can anyone help me pls. (if its possible pls not just text how to do, im > > very new and i can learn more when i see a correct code) > > > > Normally in Django you specify the models in code, and then ask Django > to create the corresponding tables. If you are using a legacy database > - one that already exists - then you will need to do more work. > > You will need to tell Django what table name each model corresponds > to. There is some excellent documentation on using django with an > existing legacy database. > > https://docs.djangoproject.com/en/1.4/howto/legacy-databases/ > > Also, I do not understand why you are creating and specifying the > database connection in the view. If you want to use Django models, you > must configure your database with Django. This is complicated by the > fact you want to use an unsupported backend. There is a 3rd party > Django ODBC backend: > > http://code.google.com/p/django-pyodbc/ > > and instructions on how to get support for those backends: > > > https://docs.djangoproject.com/en/1.4/ref/databases/#using-a-3rd-party-database-backend > > > Cheers > > Tom > -- 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/-/uBYzqHYrwo0J. 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.
Re: views on one page
Are there not more intput? pls help me, I do not go any further...! Am Mittwoch, 14. November 2012 10:50:04 UTC+1 schrieb Nebros: > Good morning > I have 2 diffrent views, every one i just needet on one page... till now. > > view one-output is the time- > @csrf_protect > def portal(request): > now = datetime.datetime.now() > return render_to_response('portal.html', {'current_date': now}, > context_instance=RequestContext(request)) > - > > view two-output are data out of a mssql db-- > def kundendaten(request): > 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 tttaad20 as x, > tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'niedereh')") > row = cursor.fetchall() > return render_to_response("kundendaten.html", { 'row': row }, > context_instance=RequestContext(request)) > --- > > in addition, i have to set the x.t_user as a variable. the value will be > given from the page before. (form/post/submit) > > how can i use this two now on one page? (i know these are two > render_to_response and i cant just use: > {% block content %}Zeit der Aktualisierung {{ current_date }}{% > endblock %} > and > {% block content %}Kundendaten {{ row }}.{% endblock %} > on one page)... > > I just failed by the try to change them... > -- 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/-/Fxv5JtTBvnAJ. 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.
from odbc to table
good morning. i have an odbc connect to a mssql db... it works and it looks like this: views--- def kundendaten(request): 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 tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name)") row = cursor.fetchall() return render_to_response("kundendaten.html", { 'row': row }, context_instance=RequestContext(request)) --- what does it do? it gives out the name and the e-mail of a customer. the values are from two tables together and with "WHERE (x.t_name = y.t_name)" i avoid redundancy. here the output of these request: --- [('Ackermann Marcel (THA) ', 'marcel.***@***.ch '), ('Adami Renate (HEI) ', 'renate.***@***.ch '), ('Ammann Cornelia (HEI) ', 'cornelia.***@***.ch '), ('Ausbildung A. Schwaller (HEI) ', 'giulia.***@***.ch '), ('General_User_NT (SYS) ', 'baan-alarm@***.ch '), ('Benz Roger (THA) ', 'roger.***@***.ch '), ('Berktold Stefan (THA) ', 'stefan.***@***.ch '), ('Biegger Christian (THA) ')] --- and now my problem... i dont know how that i can give it out into a table. i createt a modul: modul--- from django.db import models class Person(models.Model): t_name = models.CharField(max_length=30) t_mail = models.CharField(max_length=30) i dont know whether i need this and i dont know how to use the table, that it works... can anyone help me pls. (if its possible pls not just text how to do, im very new and i can learn more when i see a correct code) -- 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/-/mxc6LxvPrO8J. 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.
Re: views on one page
I need both together, because later i need another output from another database (lotus notes (i hate it)) on the same page. Can you make a code for me? im really not good (a new user)... when one part works, maybe i know than how to implements the next database by myself. :) Am Mittwoch, 14. November 2012 11:00:18 UTC+1 schrieb Martin J. Laubach: > Do you actually need both as views proper? The easiest thing would be to > factor out the fetching part of the kundendaten view, make that return just > a dictionary, then call that and update the context in the first view. > > -- 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/-/rEqNznRZ77MJ. 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.
views on one page
Good morning I have 2 diffrent views, every one i just needet on one page... till now. view one-output is the time- @csrf_protect def portal(request): now = datetime.datetime.now() return render_to_response('portal.html', {'current_date': now}, context_instance=RequestContext(request)) - view two-output are data out of a mssql db-- def kundendaten(request): 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 tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'niedereh')") row = cursor.fetchall() return render_to_response("kundendaten.html", { 'row': row }, context_instance=RequestContext(request)) --- in addition, i have to set the x.t_user as a variable. the value will be given from the page before. (form/post/submit) how can i use this two now on one page? (i know these are two render_to_response and i cant just use: {% block content %}Zeit der Aktualisierung {{ current_date }}{% endblock %} and {% block content %}Kundendaten {{ row }}.{% endblock %} on one page)... I just failed by the try to change them... -- 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/-/ZF99wn_kI_8J. 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.
Re: Forbidden (403)
Edit: first error was TypeError at /portal/... i realyzed now, the error is for the next page... > TypeError at /kundendaten/ > > pop expected at least 1 arguments, got 0 > > > > i tryed the post from this page: > http://stackoverflow.com/questions/7678231/problems-with-csrf-token > > > > now i have the error, when i press my send button, why is that? > here the error...-- > > TypeError at /kundendaten/ > > pop expected at least 1 arguments, got 0 > > Request Method:POSTRequest URL:http://127.0.0.1:8000/kundendaten/Django > Version:1.4.1Exception Type:TypeErrorException Value: > > pop expected at least 1 arguments, got 0 > > Exception Location:C:\Python27\lib\site-packages\django\template\loader.py > in render_to_string, line 178Python Executable:C:\Python27\python.exePython > Version:2.7.3 > > > - > -- 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/-/SilENNx7kGsJ. 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.
Re: Forbidden (403)
ok, i have it done. but i have now the next problem... what i have chaged: views @csrf_protect def portal(request): c = {} c.update (csrf(request)) now = datetime.datetime.now() return render_to_response('portal.html', {'current_date': now}, context_instance=RequestContext(request)) why i did it like this: by loading the page i became an error... TypeError at /kundendaten/ pop expected at least 1 arguments, got 0 i tryed the post from this page: http://stackoverflow.com/questions/7678231/problems-with-csrf-token now i have the error, when i press my send button, why is that? here the error...-- TypeError at /kundendaten/ pop expected at least 1 arguments, got 0 Request Method:POSTRequest URL:http://127.0.0.1:8000/kundendaten/Django Version:1.4.1Exception Type:TypeErrorException Value: pop expected at least 1 arguments, got 0 Exception Location:C:\Python27\lib\site-packages\django\template\loader.py in render_to_string, line 178Python Executable:C:\Python27\python.exePython Version:2.7.3 - and thx for your answers... Am Dienstag, 13. November 2012 12:27:47 UTC+1 schrieb Tom Evans: > On Mon, Nov 12, 2012 at 2:00 PM, Nebros <markusch...@gmail.com> > wrote: > > I know this is an old problem with many answers... but no one helps me. > ^^ > > what i have: > > > > Settings > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.csrf.CsrfViewMiddleware', > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.contrib.messages.middleware.MessageMiddleware', > > # Uncomment the next line for simple clickjacking protection: > > # 'django.middleware.clickjacking.XFrameOptionsMiddleware', > > ) > > --- > > > > urls-- > > from django.conf.urls import patterns > > from klasse.views import portal, kundendaten > > urlpatterns = patterns('', > > (r'^portal/$', portal), > > (r'^kundendaten/$', kundendaten), > > ) > > --- > > > > views--- > > from django.shortcuts import render_to_response > > from django.core.context_processors import csrf > > 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}) > > > > > > portal.html-- > > > > {% csrf_token %} > > > > Anfrage > > Bitte Kundennamen eingeben > > > > required="required"> > > > > > > > > > href="kundendaten"> > > > > > > > > > > I tryed a lot of variants to fix my "post" problem, but without success. > can > > anybody help me? ^^ > > thx > > *pls ignore my englisch fails > > > > There are three steps to enabling CSRF protection: > > 1) Add CsrfViewMiddleware > 2) Add csrf_token to the form > 3) Ensure that the csrf token is in the template context, by using a > RequestContext or calling the CSRF context processor directly. > > As documented here: > > https://docs.djangoproject.com/en/1.4/ref/contrib/csrf/ > > You've done 1 and 2. You haven't done 3. > > Cheers > > Tom > -- 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/-/XfyMrM8etpMJ. 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.
Re: Forbidden (403)
thanks for your answer. by point one, it doesnt contain the csrf_token parameter, but i dont know why. ^^ to see the html better, i give the full now: portal-- Kunde Kunde {% block content %}Zeit der Aktualisierung {{ current_date }}.{% endblock %} {% csrf_token %} Anfrage Bitte Kundennamen eingeben Danke fuer die Benutzung meiner Seite. source code by right clicking... Kunde Kunde Zeit der Aktualisierung Nov. 13, 2012, 11:49 a.m.. Anfrage Bitte Kundennamen eingeben Danke fuer die Benutzung meiner Seite. Am Dienstag, 13. November 2012 09:36:34 UTC+1 schrieb JirkaV: > I may be wrong, but I don't see you using {% csrf_token %} anywhere. > You're posting random snippets from your code that only loosely relate - I > have trouble finding full code for the view and all components of HTML > templates causing you trouble. > > So I'll just post a few tips: > > - before submitting the form in your browser, show the rendered HTML for > the page "right click, then View Source (or similar) - does it contain the > csrf_token parameter? (Just search for "csrf_token"). > - you can easily verify that your CSRF token is posted with the form by > putting "print request" on the first line of the view that receives the > form submission - then you should see "csrf_token" among the posted > paramaters. > - better version is to install a module to the browser you use for > debugging to view what's actually being sent. For Firefox, you could use > the excellent Firebug. > > > > On Tue, Nov 13, 2012 at 9:05 AM, Nebros <markusch...@gmail.com > > wrote: > >> kundendaten- >> {% include "header.html" %} >> Kundendaten >> {% include "header2.html" %} >> Portal >> Ausgabe Kundendaten >> {% include "sql.html" %} >> >> NameE-Mail >> '.$result['t_name'].''.$result['t_mail'].' >> >> {% include "footer.html" %} >> --- >> >> (header , header2 and footer are only for the html tags !doctype... >> blabla) >> >> Forbidden (403)- >> >> CSRF verification failed. Request aborted. >> Help >> >> Reason given for failure: >> >> CSRF cookie not set. >> >> >> In general, this can occur when there is a genuine Cross Site Request >> Forgery, or when *Django's CSRF >> mechanism*<http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ref-contrib-csrf>has >> not been used correctly. For POST forms, you need to ensure: >> >>- Your browser is accepting cookies. >>- The view function uses >> *RequestContext*<http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext>for >> the template, instead of >>Context. >>- In the template, there is a {% csrf_token %} template tag inside >>each POST form that targets an internal URL. >>- If you are not using CsrfViewMiddleware, then you must use >>csrf_protect on any views that use the csrf_token template tag, as >>well as those that accept the POST data. >> >> You're seeing the help section of this page because you have DEBUG = Truein >> your Django settings file. Change that to >> False, and only the initial error message will be displayed. >> >> You can customize this page using the CSRF_FAILURE_VIEW setting. >> >> - >> >> >> Am Montag, 12. November 2012 15:00:48 UTC+1 schrieb Nebros: >> >>> I know this is an old problem with many answers... but no one helps me. >>> ^^ >>> what i have: >>> >>> Settings--**-- >>> MIDDLEWARE_CLASSES = ( >>> 'django.middleware.csrf.**CsrfViewMiddleware', >>> 'django.middleware.common.**CommonMiddleware', >>> 'django.contrib.sessions.**middleware.SessionMiddleware', >>> 'django.contrib.auth.**middleware.**AuthenticationMiddleware', >>> 'django.contrib.messages.**middleware.MessageMiddleware', >>> # Uncomment the next line for simple clickjacking p
Re: Forbidden (403)
kundendaten- {% include "header.html" %} Kundendaten {% include "header2.html" %} Portal Ausgabe Kundendaten {% include "sql.html" %} NameE-Mail '.$result['t_name'].''.$result['t_mail'].' {% include "footer.html" %} --- (header , header2 and footer are only for the html tags !doctype... blabla) Forbidden (403)- CSRF verification failed. Request aborted. Help Reason given for failure: CSRF cookie not set. In general, this can occur when there is a genuine Cross Site Request Forgery, or when *Django's CSRF mechanism*<http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ref-contrib-csrf>has not been used correctly. For POST forms, you need to ensure: - Your browser is accepting cookies. - The view function uses *RequestContext*<http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext>for the template, instead of Context. - In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. - If you are not using CsrfViewMiddleware, then you must use csrf_protecton any views that use the csrf_token template tag, as well as those that accept the POST data. You're seeing the help section of this page because you have DEBUG = Truein your Django settings file. Change that to False, and only the initial error message will be displayed. You can customize this page using the CSRF_FAILURE_VIEW setting. - Am Montag, 12. November 2012 15:00:48 UTC+1 schrieb Nebros: > I know this is an old problem with many answers... but no one helps me. ^^ > what i have: > > Settings > MIDDLEWARE_CLASSES = ( > 'django.middleware.csrf.CsrfViewMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.contrib.messages.middleware.MessageMiddleware', > # Uncomment the next line for simple clickjacking protection: > # 'django.middleware.clickjacking.XFrameOptionsMiddleware', > ) > --- > > urls-- > from django.conf.urls import patterns > from klasse.views import portal, kundendaten > urlpatterns = patterns('', > (r'^portal/$', portal), > (r'^kundendaten/$', kundendaten), > ) > --- > > views--- > from django.shortcuts import render_to_response > from django.core.context_processors import csrf > 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}) > > > portal.html-- > > {% csrf_token %} > > Anfrage > Bitte Kundennamen eingeben > > > > > > href="kundendaten"> > > > > > I tryed a lot of variants to fix my "post" problem, but without success. > can anybody help me? ^^ > thx > *pls ignore my englisch fails > -- 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/-/K1p4e5lY1B4J. 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.
Re: Forbidden (403)
When i put in a variable in my type="text" and push type="submit" (by the step to next page)... Am Montag, 12. November 2012 16:52:20 UTC+1 schrieb Vibhu Rishi: > When is it that you are getting the 403 ? > > > On Mon, Nov 12, 2012 at 7:30 PM, Nebros <markusch...@gmail.com > > wrote: > >> I know this is an old problem with many answers... but no one helps me. ^^ >> what i have: >> >> Settings >> MIDDLEWARE_CLASSES = ( >> 'django.middleware.csrf.CsrfViewMiddleware', >> 'django.middleware.common.CommonMiddleware', >> 'django.contrib.sessions.middleware.SessionMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware', >> 'django.contrib.messages.middleware.MessageMiddleware', >> # Uncomment the next line for simple clickjacking protection: >> # 'django.middleware.clickjacking.XFrameOptionsMiddleware', >> ) >> --- >> >> urls-- >> from django.conf.urls import patterns >> from klasse.views import portal, kundendaten >> urlpatterns = patterns('', >> (r'^portal/$', portal), >> (r'^kundendaten/$', kundendaten), >> ) >> --- >> >> views--- >> from django.shortcuts import render_to_response >> from django.core.context_processors import csrf >> 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}) >> >> >> portal.html-- >> >> {% csrf_token %} >> >> Anfrage >> Bitte Kundennamen eingeben >> >> >> >> >> >> > href="kundendaten"> >> >> >> >> >> I tryed a lot of variants to fix my "post" problem, but without success. >> can anybody help me? ^^ >> thx >> *pls ignore my englisch fails >> >> -- >> 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/-/iMXtpFVaRp8J. >> 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. >> > > > > -- > Simplicity is the ultimate sophistication. - Leonardo da Vinci > Life is really simple, but we insist on making it complicated. - Confucius > -- 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/-/XtkJC5PnvpQJ. 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.
Forbidden (403)
I know this is an old problem with many answers... but no one helps me. ^^ what i have: Settings MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) --- urls-- from django.conf.urls import patterns from klasse.views import portal, kundendaten urlpatterns = patterns('', (r'^portal/$', portal), (r'^kundendaten/$', kundendaten), ) --- views--- from django.shortcuts import render_to_response from django.core.context_processors import csrf 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}) portal.html-- {% csrf_token %} Anfrage Bitte Kundennamen eingeben I tryed a lot of variants to fix my "post" problem, but without success. can anybody help me? ^^ thx *pls ignore my englisch fails -- 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/-/iMXtpFVaRp8J. 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.
Re: more problems than one
ok, that was not really useful for me... :( -- 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/-/k8IF1Joy_GcJ. 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.
Re: more problems than one
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. 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.
Re: more problems than one
hmm? there is more than just one page... what do you mean tochange, and what does it make? Am Freitag, 9. November 2012 11:06:03 UTC+1 schrieb Sergiy Khohlov: > add the / at the end of your page > > 2012/11/9 Nebros <markusch...@gmail.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" %} >> Kunde >> {% include "header2.html" %} >> Kunde >> {% include "time.html" %} >> >> >> Anfrage >> Bitte Kundennamen eingeben >> >> >> >> >> >> >> >> >> {% 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" %} >> Kundendaten >> {% include "header2.html" %} >> Portal >> Ausgabe Kundendaten >> {% 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) >> >> NameE-Mail >> >> '.$result['t_name'].''.$result['t_mail'].' #i >> tryed it with php, but that won't work... thats why i deleted a part of php >> >> {% 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 tttaad20 as x, >> tttcmf20 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 >> >> -- >> 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. >> > > -- 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/-/z35Svk32M6wJ. 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.
more problems than one
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" %} Kunde {% include "header2.html" %} Kunde {% include "time.html" %} Anfrage Bitte Kundennamen eingeben {% 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" %} Kundendaten {% include "header2.html" %} Portal Ausgabe Kundendaten {% 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) NameE-Mail '.$result['t_name'].''.$result['t_mail'].' #i tryed it with php, but that won't work... thats why i deleted a part of php {% 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 tttaad20 as x, tttcmf20 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 -- 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-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.