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 tttaad200000 as x, tttcmf200000 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 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% endblock %} and {% block content %}<p>Kundendaten {{ row }}.</p>{% endblock %} on one page)...
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.
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.
> 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 tttaad200000 as x, > tttcmf200000 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 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% > endblock %} > and > {% block content %}<p>Kundendaten {{ row }}.</p>{% endblock %} > on one page)...
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.
On Thu, Nov 15, 2012 at 2:33 PM, Nebros <markuschriste...@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 tttaad200000 as x,
>> tttcmf200000 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 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{%
>> endblock %}
>> and
>> {% block content %}<p>Kundendaten {{ row }}.</p>{% endblock %}
>> on one page)...
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@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
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 tttaad200000 as x, tttcmf200000 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---------------------------------- <h2>Ausgabe Kundendaten</h2> {% block content1 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% endblock %} {% block content2 %}<p>Kundendaten {{ row }}.</p>{% 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<javascript:> > > 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 tttaad200000 as x, >>> tttcmf200000 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 %}<p>Zeit der Aktualisierung {{ current_date }}</p>{% >>> endblock %} >>> and >>> {% block content %}<p>Kundendaten {{ row }}.</p>{% endblock %} >>> on one page)...
>> To post to this group, send email to django...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com <javascript:>. >> 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