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) oddity:

return render_to_response(
   template,
   {'important': 1},
   context_instance=RequestContext(
       request, processors=[important_processor])
)

What important_processor() does is return a dictionary {''important":
FOO} where the value of FOO depends on something in the request.

Many other views' render_to_response() had this as its
context_instance, but they did not define 'important" in the
dictionary before the context_instance, so I replaced them with:

return render(
  request,
  template,
  important_processor(request) + {'whatever': 'was', 'in': 'here'}
)

In the first example I'm having some trouble figuring out which value
for "important" is visible to the template: is it 1, or whatever
important_processor() generates?

If I print what I think is context that is used to render the
template, I get a list of multiple dictionaries. The last two both
have a "important"-key, but with different values. {'important': 1}
comes first of the two.

I am neck deep in the template rendering code right now and I'm quite lost.


HM


(For statistics' sake , some 95% of the render_to_response()s looked like this:

return render_to_response(
  some_template,
  some_dict,
  context_instance=RequestContext(request)
)

)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACQ%3DrrfLhhHrtKVSvcwJ7SmNyePdybEhO50%2Bepd8hcuLEG5sgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to