This is only used in one app, and one views.py out of 38. There's only
this one views.py remaining that uses render_to_response with
context_instance. If this was modern Django code written by me I would
have used class-based views and a mixin modifying get_context_data
(Thank $deity for
.context_processors.messages',
'django.template.context_processors.request',
'general.context_processors.extra_context',
],
},
},
]
-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of H
I'm upgrading a rather large code base from django 1.7, with the
ultimate goal to have it run on 1.11, as the code isn't fully verified
to run on python 3 yet.
I'm replacing `render_to_response()` with `render()` everywhere a
RequestContext is used, and came upon this (simplified)
ulario de cuenca'
>
> dc=request.POST['descripcion_cuenca']
> idobra=request.POST['obra']
>
> cuenca=Cuenca(gid_obra_id=idobra, descripcion_cuenca=dc)
>
> cuenca.save()
>
> return rende
lo = 'Formulario de cuenca'
dc=request.POST['descripcion_cuenca']
idobra=request.POST['obra']
cuenca=Cuenca(gid_obra_id=idobra, descripcion_cuenca=dc)
cuenca.save()
return render_to_response('ob
gt; I want passed on (in this case a simple geographic location such as a city
> or zip code)? Again, I know I can do it with render, but the linked post
> suggests otherwise.
>
> The writer of hte post also said that, in the context of
> render_to_response that it should be used m
but the linked post
suggests otherwise.
The writer of hte post also said that, in the context of render_to_response
that it should be used most of the time.
Help would be appreciated, thanks!
--
You received this message because you are subscribed to the Google Groups
"Django users&qu
I don't know what is happening but I've solved with a workaround:
dummy = self.request.user.is_authenticated()
calling is_authenticated before returning render_to_response solves the
problem, because request.user is "casted" to the actual user instance,
in
The problem seems to be related with SimpleLazyObject, wrapping the
auth.user.
If during debugging I access the function, everything works fine. It's
enough to have the Variables windows open in PyDev.
If I do not access it, it isn't resolved to the actual user instance (in my
case AnonymousUser
st context
processors.
I paste an excerpt, where I do the render_to_response call directly from
the form_valid method, just to test it.
class ProjectCreateView(FormView):
"""Create view."""
(...)
def form_valid(self, form):
&
ur assistance
>
>
>
>
>
>
>
> On Mon, Nov 7, 2011 at 2:04 PM, Tom Evans wrote:
> > On Mon, Nov 7, 2011 at 3:59 PM, jay K.
> > wrote:
> > > hi, Tom
>
> > > thanks for the reply
>
> > > what I actually want to do is to
> > &g
s about 'object'. ?object also works, ?? prints more.
In [1]: from django.shortcuts import render_to_response
In [2]:
thanks guys.
-Ganesh.
Did I learn something today? If not, I wasted it.
On Fri, Nov 11, 2011 at 9:06 PM, Daniel Roseman wrote:
> On Friday, 11 November 2011 1
met the same problem the solution.
Thans again.
regards,
Bowen
在 2011年11月11日星期五,Daniel Roseman 写道:
> On Friday, 11 November 2011 13:49:08 UTC, Ganesh-Bugcy wrote:
>>
>> Hi ,
>>
>> I have tried to load render_to_response module. it's through error. I
>> have
:
> Hi ,
>
> I have tried to load render_to_response module. it's through error. I
> have tried download and install the module
> https://github.com/jgorset/django-shortcuts
> installed sucessfully, But not load any one of you help me guys.
>
>
> dhana013 ~ $ ipython
On Friday, 11 November 2011 13:49:08 UTC, Ganesh-Bugcy wrote:
>
> Hi ,
>
> I have tried to load render_to_response module. it's through error. I
> have tried download and install the module
> https://github.com/jgorset/django-shortcuts
> installed sucessfully, But not lo
Hi ,
I have tried to load render_to_response module. it's through error. I
have tried download and install the module
https://github.com/jgorset/django-shortcuts
installed sucessfully, But not load any one of you help me guys.
dhana013 ~ $ ipython
Python 2.6.5 (r265:79063, Apr 16 2010,
On Thu, Nov 10, 2011 at 11:26 AM, Ganesh Kumar wrote:
> Hi
> How to install render_to_response module.
> please guide me.
>
> In [10]: from django.shortcuts import render_to_response
> ---
Hi
How to install render_to_response module.
please guide me.
In [10]: from django.shortcuts import render_to_response
---
ImportError Traceback (most recent call last)
/root/django-shortcuts
ote:
> > hi, Tom
> >
> > thanks for the reply
> >
> > what I actually want to do is to
> > list several templates in the render_to_response
> > function and be able to choose which one to use
> >
> > can I choose which template to use?
> >
>
PM, Tom Evans wrote:
> On Mon, Nov 7, 2011 at 3:59 PM, jay K.
> wrote:
> > hi, Tom
> >
> > thanks for the reply
> >
> > what I actually want to do is to
> > list several templates in the render_to_response
> > function and be able to choose which
On Mon, Nov 7, 2011 at 3:59 PM, jay K. wrote:
> hi, Tom
>
> thanks for the reply
>
> what I actually want to do is to
> list several templates in the render_to_response
> function and be able to choose which one to use
>
> can I choose which template to use?
>
>
hi, Tom
thanks for the reply
what I actually want to do is to
list several templates in the render_to_response
function and be able to choose which one to use
can I choose which template to use?
thanks again, and let me know if my question is clear enough
On Mon, Nov 7, 2011 at 12:18 PM, Tom
On Mon, Nov 7, 2011 at 3:09 PM, jay K. wrote:
>
> Hello
>
> I have a view with the following render_to_template function
>
> ...
>
> return render_to_response( 'template/template.html', {var'': var},
> context_instance=RequestContext(request))
>
Hello
I have a view with the following render_to_template function
...
return render_to_response( 'template/template.html', {var'': var},
context_instance=RequestContext(request))
...
I want the render_to_response to point to more than 1 template. So far
I've tri
it possible to make some kind of injection using it
>> this way? Is autoescape a better option?
>>
>
> They are all variants of the same thing. These are all equivalent:
>
> {{ foo|safe }}
>
> {% autoescape off %}
> {{ foo }}
> {% endautoescape %}
>
>
autoescape a better option?
>
They are all variants of the same thing. These are all equivalent:
{{ foo|safe }}
{% autoescape off %}
{{ foo }}
{% endautoescape %}
from django.utils.safestring import mark_safe
return render_to_response('...', { 'foo': mark_safe(foo) })
They
> template
> > variable.
> >
> > What I am doing is:
> >
> > view.py
> > def view(request, id):
> >thing = get_object_or_404(Object, pk=id)
> >if blablabla:
> > return render_to_response('template.html'),
>
gt;
> What I am doing is:
>
> view.py
> def view(request, id):
> thing = get_object_or_404(Object, pk=id)
> if blablabla:
> return render_to_response('template.html'),
> {'html_message': ' We recommend that you click href="thing.get_upd
as a template
> variable.
>
> What I am doing is:
>
> *view.py*
> def view(request, id):
>thing = get_object_or_404(Object, pk=id)
>if blablabla:
> return render_to_response('template.html'),
> {'html_message': ' We recommend that you cl
2011/3/10 Thiago Carvalho D' Ávila :
> I'm having some problem while trying to render some HTML code as a template
> variable.
>
> What I am doing is:
>
> view.py
> def view(request, id):
> thing = get_object_or_404(Object, pk=id)
> if blablab
I'm having some problem while trying to render some HTML code as a template
variable.
What I am doing is:
*view.py*
def view(request, id):
thing = get_object_or_404(Object, pk=id)
if blablabla:
return render_to_response('template.html'),
{'html_message':
On Friday, January 7, 2011 4:05:27 PM UTC, hank23 wrote:
>
> Another question about forms. So the form name or names that I pass in
> the dictionary to the response can also be named anything and aren't
> required to be of a specific form name format right?
>
Yes, that's correct. There's no nam
t;
> return render_to_response('contact.html',
> { my_data_dictionary(including an entry for 'form': form) },
> context_instance=RequestContext(request))
>
> On Jan 7, 9:42 am, Daniel Roseman wrote:
>
>
>
> > On Friday, January 7, 2011 3:38:
I see. So then I would code it something like this then:
return render_to_response('contact.html',
{ my_data_dictionary(including an entry for 'form': form) },
context_instance=RequestContext(request))
On Jan 7, 9:42 am, Daniel Roseman wrote:
> On Friday, Jan
On Friday, January 7, 2011 3:38:10 PM UTC, hank23 wrote:
>
> So then when using a form do I code it something like this then:
>
>
> return render_to_response('contact.html', {
> 'form': form,
> my_data_dictionary,
> context_instance=R
So then when using a form do I code it something like this then:
return render_to_response('contact.html', {
'form': form,
my_data_dictionary,
context_instance=RequestContext(request))
})
I ask because it's confusing me when using a form for how to code
On Friday, January 7, 2011 3:15:33 PM UTC, hank23 wrote:
>
> In the topics forms documentation there's an example of using a form
> in a view which shows a return statement using a render_to_respone
> shortcut like this:
>
> return render_to_response('contact.h
In the topics forms documentation there's an example of using a form
in a view which shows a return statement using a render_to_respone
shortcut like this:
return render_to_response('contact.html', {
'form': form,
})
but in the shortcuts documentation it
Just have my_fnc return a dictionary (or other object), rather than the
whole rendered response:
def search(request):
..
answ = my_fnc(roots)
return render_to_response("my_fnc.html", { "answ" : answ['FindWord'] } )
def my_fnc( roots ):
FindWor
How formulate correctly the code below:
[code]
#views.py
def search(request):
..
answ = my_fnc(roots)
return render_to_response("my_fnc.html", { "answ" : answ } )
def my_fnc( roots ):
FindWord=authors.objects.filter("name"__contains=roots)
I would caution that what you are doing may make maintenance difficult
later. You may want to evaluate using whether creating the table in the
template is more appropriate.
-- Casey
On 08/25/2010 09:21 AM, Tim Sawyer wrote:
On 25/08/10 13:36, mdolphin wrote:
OK, that's probably a Newbee Que
Use the "safe" filter to disable the auto-escaping that templates
apply to all variables:
http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#safe
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to djan
On 25/08/10 13:36, mdolphin wrote:
OK, that's probably a Newbee Question:
My Code generates an HTML-Table, that I want to show up inside a {%
block %} in my Template. All I get is an encoded output of my
generated HTML-Sourcecode inside the Template. so i.e becomes
and so on. How could I a
OK, that's probably a Newbee Question:
My Code generates an HTML-Table, that I want to show up inside a {%
block %} in my Template. All I get is an encoded output of my
generated HTML-Sourcecode inside the Template. so i.e becomes
and so on. How could I achieve it to get my generated HTML-
C
Thanks all!
I will try a combination of these pointers. server/client
communication patterns seems to be a recurring theme (or nightmare!)
of mine.
This conversation has been very helpful and reassuring - I can see
that the hard and fast rule is 'when in doubt, json it'
On Jun 17, 10:31 am, Ian McDowall wrote:
>
> In some cases, I don't use templates to build a JSON response. It can
> be straightforward to write it as a string inline. I don't personally
> yet use the built in Python JSON module as I don't want to limit the
> Python versions that I can deploy
Sorry, other posters have picked up two of my errors.
It is a while since I used application/json and I was running on
(incorrect) memory. My reasoning for using plain text is as follows.
I regard parsing JSON using eval() as a security risk on the client
side. If you have complete control of th
I was just copying Ian's choice of mimetype - see Ian's comment above
"I choose text/plain deliberately but you might choose text/json (or
something else)."... Although it's worth pointing out that "text/json"
shouldn't be used, since "application/json" is, as you rightly point,
the mimetype for js
Hi!
Matt Hoskins wrote:
> return HttpResponse(simplejson.dumps(data),mimetype='text/plain)
Small correction: mime type should be application/json.
--
Dmitry Dulepov
Twitter: http://twitter.com/dmitryd/
Web: http://dmitry-dulepov.com/
--
You received this message because you are subscribed to
Django has an escapejs filter so if you're using a template to
generate json you'd be safer doing, e.g.:
"first_name":"{{ one_member.first_name|escapejs }}"
That way if someone sticks something untoward (like a double quote) in
your first_name or last_name fields it won't break things :).
For th
contain characters that break
the JSON (e.g. quotation marks).
Cheers
Ian
On Jun 16, 8:46 pm, Alex wrote:
> Thanks all. I may go with Matt's idea of serialising html + other data
> to json and decoding client side. I'm not totally keen though because
> this abandons a very
Thanks all. I may go with Matt's idea of serialising html + other data
to json and decoding client side. I'm not totally keen though because
this abandons a very nice rollup of functionality in django's
render_to_response (I am not familiar with how to write the template
as JSON a
gt; Please can anyone help with an app architecture problem I am having?
> (I am quite new to Django)
>
> I have an app which which serves up XHR requests (via YUI3 io
> uitility) to urlpatterns. The views make HttpResponses using
> render_to_response like so:
>
> retu
Perhaps instead of using render_to_response to generate the response,
render the template output to a string and then stuff that in the data
structure that you serialise to json along with the other data?
Regards,
Matt
On Jun 16, 1:17 pm, Alex wrote:
>
> But the problem I have - and I
e HttpResponses using
> render_to_response like so:
>
> return render_to_response("registration/register.html", {
> 'form': form,
> }, context_instance=RequestContext(request))
>
> That is all fine: The html content is rendered in the relevant div
> (using a
Hi,
Please can anyone help with an app architecture problem I am having?
(I am quite new to Django)
I have an app which which serves up XHR requests (via YUI3 io
uitility) to urlpatterns. The views make HttpResponses using
render_to_response like so:
return render_to_response("registr
def my_root_page(request):
#t = get_template('root.html')
html = 'Please Work!'
#t.render(Context({}))
return HttpResponse(html)
def current_datetime(request):
now = datetime.datetime.now()
return render_to_response('current_datetime.html',
{
On May 26, 8:19 pm, Nate wrote:
> I'm teaching myself django and I'm having an issue with
> render_to_response. I am passing it a template and a dictionary.
> When I view the page on a local host, it displays the entire template,
> including HTML tags, instead of formatting
I'm teaching myself django and I'm having an issue with
render_to_response. I am passing it a template and a dictionary.
When I view the page on a local host, it displays the entire template,
including HTML tags, instead of formatting the page according to the
tags. I don't have
Yeah it's a twisted idea, but I'm going to use it for informative 403
405 pages.
On Dec 4, 3:51 pm, Daniel Roseman wrote:
> On Dec 4, 8:37 am, chefsmart wrote:
>
> > According to the docs
> > athttp://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to..
On Dec 4, 8:37 am, chefsmart wrote:
> According to the docs
> athttp://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to...
> the render_to_response shortcut "Renders a given template with a given
> context dictionary and returns an HttpResponse object with tha
According to the docs at
http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response
the render_to_response shortcut "Renders a given template with a given
context dictionary and returns an HttpResponse object with that
rendered text."
The HttpResponse object have
e
>
> >http://www.example.com/taskamanger/edit_task/5
>
> > They make some change to the task - say change the due date. But they
> > make an error which is caught on the server side. When my server code
> > runs, it calls render_to_response to re-render the page t
nger/edit_task/5
>
> They make some change to the task - say change the due date. But they
> make an error which is caught on the server side. When my server code
> runs, it calls render_to_response to re-render the page to display the
> error. Howevever, because their original u
make an error which is caught on the server side. When my server code
runs, it calls render_to_response to re-render the page to display the
error. Howevever, because their original url was
http://www.example.com/taskmanager/edit_task/5#comment_4
they are now taken back to the page with comment_4
Did you isolate the problem yet?
It could also be the query itself. You might have to add indexes into
the database to get good results.
How much time does the query take if you run it in naive SQL without the
rendering?
Low Kian Seong wrote:
> Pretty much confirmed it's the rendering or pul
On 11/3/09, esatterwh...@wi.rr.com wrote:
>
> You might want to consider installing the debug toolbar (
> http://github.com/robhudson/django-debug-toolbar ).
Yeah, I tried this before but then when you are trying to generate an
Excel spreadsheet somehow it fails to capture the right data and
dis
I strongly suggest you to use pagination here.
2009/11/3 Low Kian Seong
>
> I have about 3k plus record in my db table and am trying to do a
> simple render_to_response of a template sending it the results of a
> query. I debugged this and found that the total time taken for an
>
On 3 nov, 12:12, Low Kian Seong wrote:
> Pretty much confirmed it's the rendering or pulling of data from database:
>
> 1. I tried to render a html page instead of Excel. Same speed.
> So this
> kicks out the theory of rending of excel is slowing the page down.
I assume you meant "csv", not "Exc
You might want to consider installing the debug toolbar (
http://github.com/robhudson/django-debug-toolbar ).
it displays the amount of time taken for all of the rendering steps.
It will defiantly help you narrow down the major culprits.
On Nov 3, 5:12 am, Low Kian Seong wrote:
> Pretty much co
Pretty much confirmed it's the rendering or pulling of data from database:
1. I tried to render a html page instead of Excel. Same speed. So this
kicks out the theory of rending of excel is slowing the page down.
2. I tried shorting out all the data from the rendered page. Page came
up in less t
On 3 nov, 09:09, Low Kian Seong wrote:
> But I am confused here. How do iterate through the data another time?
> Do I call the select_related in my views.py code like:
>
> manager_info = found_entries.select_related()
>
> then how do i iterate through manager_info in my template?
That's not how
On Tue, Nov 3, 2009 at 1:17 AM, Low Kian Seong wrote:
> There is a query page where the start_date and end_date is being sent.
> Then the do_defender_advanced will process it and generate an Excel
> using the template.
One other thing is that the Django template system isn't really
optimized for
On Tue, Nov 3, 2009 at 3:41 PM, James Bennett wrote:
>
> On Tue, Nov 3, 2009 at 1:17 AM, Low Kian Seong wrote:
>> There is a query page where the start_date and end_date is being sent.
>> Then the do_defender_advanced will process it and generate an Excel
>> using the template.
>
> For each obje
;>>>> Low Kian Seong kirjoitti:
>>>>>> I have about 3k plus record in my db table and am trying to do a
>>>>>> simple render_to_response of a template sending it the results of a
>>>>>> query. I debugged this and fo
Kian Seong kirjoitti:
>>>>> I have about 3k plus record in my db table and am trying to do a
>>>>> simple render_to_response of a template sending it the results of a
>>>>> query. I debugged this and found that the total time taken for an
>>>>&
On Tue, Nov 3, 2009 at 1:17 AM, Low Kian Seong wrote:
> There is a query page where the start_date and end_date is being sent.
> Then the do_defender_advanced will process it and generate an Excel
> using the template.
For each object you are displaying the values of four foreign keys.
Each time
On Tue, Nov 3, 2009 at 3:07 PM, Jani Tiainen wrote:
>
> Low Kian Seong kirjoitti:
>> On Tue, Nov 3, 2009 at 1:33 PM, Jani Tiainen wrote:
>>> Low Kian Seong kirjoitti:
>>>> I have about 3k plus record in my db table and am trying to do a
>>>> simpl
Low Kian Seong kirjoitti:
> On Tue, Nov 3, 2009 at 1:33 PM, Jani Tiainen wrote:
>> Low Kian Seong kirjoitti:
>>> I have about 3k plus record in my db table and am trying to do a
>>> simple render_to_response of a template sending it the results of a
>>> query
On Tue, Nov 3, 2009 at 1:33 PM, Jani Tiainen wrote:
>
> Low Kian Seong kirjoitti:
>> I have about 3k plus record in my db table and am trying to do a
>> simple render_to_response of a template sending it the results of a
>> query. I debugged this and found that the
On Mon, Nov 2, 2009 at 10:44 PM, Low Kian Seong wrote:
> I have about 3k plus record in my db table and am trying to do a
> simple render_to_response of a template sending it the results of a
> query. I debugged this and found that the total time taken for an
> operation like this i
Low Kian Seong kirjoitti:
> I have about 3k plus record in my db table and am trying to do a
> simple render_to_response of a template sending it the results of a
> query. I debugged this and found that the total time taken for an
> operation like this is 50 seconds! Is there anyway t
I have about 3k plus record in my db table and am trying to do a
simple render_to_response of a template sending it the results of a
query. I debugged this and found that the total time taken for an
operation like this is 50 seconds! Is there anyway to speed this up?
--
Low Kian Seong
blog
IMHO Yes,
otherwise the context_processor variable won't be available in template
-djibon-
On Thu, Oct 22, 2009 at 11:43 AM, jul wrote:
>
> But I still have to pass RequestContext(request) to render_to_response
> if I'm not using generic views, right?
>
> On Oct 2
But I still have to pass RequestContext(request) to render_to_response
if I'm not using generic views, right?
On Oct 21, 8:38 pm, Andrew Ingram wrote:
> jul wrote:
> > hi,
>
> > in my base.html template I've got a header which needs httprequest
> > (request.p
jul wrote:
> hi,
>
> in my base.html template I've got a header which needs httprequest
> (request.path, request.user.is_authenticated...).
> In all my views I'm passing the request object to render_to_response.
> Is there any better way to do that?
>
> thanks
hi,
in my base.html template I've got a header which needs httprequest
(request.path, request.user.is_authenticated...).
In all my views I'm passing the request object to render_to_response.
Is there any better way to do that?
On Wed, Aug 19, 2009 at 8:30 AM, Janne Peltola wrote:
>
> Template rendering fails when both form data and a tuple are passed to
> render_to_response.
>
> Python: 2.6.2; Django: 1.1; Environment: Windows + built-in dev server
>
> I use the standard django.contrib.auth.m
Template rendering fails when both form data and a tuple are passed to
render_to_response.
Python: 2.6.2; Django: 1.1; Environment: Windows + built-in dev server
I use the standard django.contrib.auth.models.User and .Group models.
View:
class FuksiForm(forms.Form):
ryhmat
On Jul 21, 2009, at 5:21 PM, Juan Hernandez wrote:
> Hi there,
>
> i have two questions in my mind.
>
> 1- Let's say that I have tens of views. Do I always have to use
> render_to_response? I find it totally against DRY. My solution was
> creating a wrapper that w
Hi there,
i have two questions in my mind.
1- Let's say that I have tens of views. Do I always have to use
render_to_response? I find it totally against DRY. My solution was creating
a wrapper that would take as arguments the template file name and a
dictionary with all the parameters for
I think the closest you could get to a painless implementation of what
you need, for existing apps, could be to create a method named
something like "render_to_json_response", that behave the way you want
and have the appropriate "views" modules in each app import it as
On Mon, 2009-03-16 at 18:34 -0700, Preston Timmons wrote:
> I am wondering if render_to_response is really the proper function you
> are looking for.
>
> For instance, here is a simple view that returns json using
> HttpResponse without need of a template:
He was wanting to hi
I am wondering if render_to_response is really the proper function you
are looking for.
For instance, here is a simple view that returns json using
HttpResponse without need of a template:
import simplejson
from django.http import HttpResponse
def output_json(request):
data = [
dict
On Mon, 2009-03-16 at 20:05 -0400, Malinka Rellikwodahs wrote:
[...]
> Unless I'm mistaken it should be fairly simple in this case to create
> your own set of templates for each of the django apps you're using and
> then have them output the data you need as json text instead of as
> html
Ooh ...
ext dict
> as JSON instead
> of rendering the html template.
>
> Is it possible to override render_to_response so all the apps using it will
> respond with JSON without
> actually touching the apps code? I don't want to create a middleware that
> will modify the response
> context dict as JSON instead
> of rendering the html template.
>
> Is it possible to override render_to_response so all the apps using it
> will respond with JSON without
> actually touching the apps code?
Not really, no. Monkey-patching like that is gene
o override render_to_response so all the apps using it will
respond with JSON without
actually touching the apps code? I don't want to create a middleware that
will modify the response because
then I have the overhead of rendering the html template.
Thanks
--~--~-~--~~~-
t version and have some problem
> > with the render_to_response to render a template. Here is a short
> > snippet:
>
> > return render_to_response('index.html', {
> > 'form': form,
> > 'ops' : ops,
> > })
On Fri, 2009-03-13 at 21:08 -0700, ihome wrote:
> Hi,
>
> I am using the latest django development version and have some problem
> with the render_to_response to render a template. Here is a short
> snippet:
>
> return render_to_response('index.html&
1 - 100 of 163 matches
Mail list logo