Django on Apache web server dict site does not have render_context attribute

I have a problem, I uploaded my Django project to a web server running apache, mod_python and django. On the computer, I developed the following works:

nameBox = getNamesBox().render(locals()) 

-

 def getNamesBox(): users = User.objects.filter() templateString = '<select name="name box">' for user in users: templateString += '<option value="' + user.name + '"> ' + user.name + '</option>' templateString += '</select>' template = Template(templateString) return template 

But on the web server when starting from apache or manage.py server it says

 AttributeError at /order_site/order/ 'dict' object has no attribute 'render_context' 

The code on both machines is identical, so it seems to me that maybe this is another problem? He cannot display my form, and I do not know why.

+6
source share
1 answer

The render() method on Template takes a Context object as its argument, not a dict. You will need to build a Context object from a dict, for example.

 namedbox = getNamesBox().render(Context(locals())) 
+11
source

Source: https://habr.com/ru/post/890422/


All Articles