I am not able to run the following code

38 views
Skip to first unread message

Madhusudhana H V

unread,
May 26, 2016, 7:44:02 AM5/26/16
to Django users
I am trying to execute the following code. But I am getting error at step 2, namely ">>> t = template.Template('My name is {{ name }}.')"
Kindly help me out of this.

>>>
from django import template >>> t = template.Template('My name is {{ name }}.') >>> c = template.Context({'name': 'Adrian'}) >>> print t.render(c) My name is Adrian. >>> c = template.Context({'name': 'Fred'}) >>> print t.render(c) My name is Fred.

Thanks and Regards,
Madhusudhana H V

Gergely Polonkai

unread,
May 26, 2016, 11:04:55 AM5/26/16
to Django users
I don’t see any error here; what is the error message you see?

--
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...@googlegroups.com.
To post to this group, send email to django...@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/1da7713e-5019-4a96-b026-30ff4ecc13bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Akhil Lawrence

unread,
May 28, 2016, 10:22:01 AM5/28/16
to Django users
Hi Madhusudhana,

When you try to create the instance of Template, its looking for settings that is why you are getting error.

You cannot play in python shell without creating django project

Create the project and use django shell. The following code snippets may help you in creating project (execute following in terminal),

django-admin startproject madhu
cd madhu
./manage.py shell
Reply all
Reply to author
Forward
0 new messages