Friday, May 27, 2016

Re: I am not able to run the following code

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







On Thursday, 26 May 2016 17:14:02 UTC+5:30, Madhusudhana H V wrote:
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

--
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/fe41438c-ed6b-4396-a4f4-a7a26e398732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment