Monday, November 20, 2017

Re: Why do I get this error "context must be a dict rather than Context." ?

As far as I know, context is always built through key, value pair. But check for it before coming to any conclusion

Hello,

Regards,
Amitesh Sahay

primary :: 91-907 529 6235



On Monday 20 November 2017, 6:08:00 PM IST, pallavi pund <pund.pallavi@gmail.com> wrote:


This helped me too . thank you

On Sunday, April 30, 2017 at 4:15:32 AM UTC+5:30, Tim Graham wrote:
It looks like the tutorial you're following hasn't been updated for Django 1.11.

Line 20 should pass a dict rather than Context:

t.render({'current_date': now})

It's related to this change in Django 1.11: https://docs.djangoproject. com/en/dev/releases/1.11/# django-template-backends- django-template-render- prohibits-non-dict-context

On Saturday, April 29, 2017 at 5:44:57 PM UTC-4, Pubudu Goonetilleke wrote:

My code : I am following tutorial on Django site and this is where I got stuck

"current_datetime"
I am not sure why I get the Type Error at line 20. Its same as tutorial. 


When I run the server, I get the following error : 

TypeError at /time/

context must be a dict rather than Context.
Request Method:GET
Request URL:http://127.0.0.1:8000/time/
Django Version:1.11
Exception Type:TypeError
Exception Value:
context must be a dict rather than Context.
Exception Location:D:\Users\Pubudu\AppData\Local\ Programs\Python\Python36\lib\ site-packages\django\template\ context.py in make_context, line 287
Python Executable:D:\Users\Pubudu\AppData\Local\ Programs\Python\Python36\ python.exe
Python Version:3.6.1
Python Path:
['C:\\Users\\Pubudu\\ workspace\\hello',   'D:\\Users\\Pubudu\\AppData\\ Local\\Programs\\Python\\ Python36\\python36.zip',   'D:\\Users\\Pubudu\\AppData\\ Local\\Programs\\Python\\ Python36\\DLLs',   'D:\\Users\\Pubudu\\AppData\\ Local\\Programs\\Python\\ Python36\\lib',   'D:\\Users\\Pubudu\\AppData\\ Local\\Programs\\Python\\ Python36',   'D:\\Users\\Pubudu\\AppData\\ Local\\Programs\\Python\\ Python36\\lib\\site-packages']
Server time:Sat, 29 Apr 2017 21:35:31 +0000

Traceback Switch to copy-and-paste view

  • D:\Users\Pubudu\AppData\Local\ Programs\Python\Python36\lib\ site-packages\django\core\ handlers\exception.py in inner
    1.             response = get_response(request)
      ...
  • D:\Users\Pubudu\AppData\Local\ Programs\Python\Python36\lib\ site-packages\django\core\ handlers\base.py in _get_ response
    1.                 response = self.process_exception_by_ middleware(e, request)
      ...
  • D:\Users\Pubudu\AppData\Local\ Programs\Python\Python36\lib\ site-packages\django\core\ handlers\base.py in _get_ response
    1.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)


--
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+unsubscribe@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/07154b8b-6812-4491-96de-02f89606976c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment