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
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
> "current_datetime"
> I am not sure why I get the Type Error at line 20. Its same as tutorial.
>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>When
>
> I run the server, I get the following error :
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
> 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 <http://127.0.0.1:8000/time/#>
>
> -
>
> D:\Users\Pubudu\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py
> in inner
> 1.
>
> response = get_response(request)
>
> ...
> ▶ Local vars <http://127.0.0.1:8000/time/#>
> -
>
> 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)
>
> ...
> ▶ Local vars <http://127.0.0.1:8000/time/#>
> -
>
> 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)
>
>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
>
> <https://lh3.googleusercontent.com/-4kF2Od8XM64/WQUIyjnP_YI/AAAAAAAA2-s/2kGkTbViOjI5UA-UxqrYZrBjx1SElQOyQCLcB/s1600/code.png>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/8456cbd1-4652-4e1c-86a8-f4127e7f3ec5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.