Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
like this: your_project--- |---__init__.py |---settings.py |---urls.py |---manage.py |---app_A--- | |---__init__.py |---models.py |---view.py |---templates--- | |---index.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
Thank you for the clarification DR. I finished the beginning tutorial on djangoproject.com. I'm certainly going to need a lot more practice. I'll fix my code with your changes. Best, SB On Fri, Mar 2, 2012 at 2:21 PM, Daniel Rosemanwrote: > On Friday, 2 March 2012 21:47:54 UTC, Django_for_SB wrote: >> >> Thank you everyone for your very insightful and helps remarks. I had 2 >> issues with my code: >> >> 1) I didn't properly separate my directory strings with commas and >> 2) I need to code the directory structure, and the absolute path to the >> file itself. >> >> Here is the correct code from within settings.py: >> >> TEMPLATE_DIRS = ( >> # Put strings here, like "/home/html/django_templates" or >> "C:/www/django/templates". >> # Always use forward slashes, even on Windows. >> # Don't forget to use absolute paths, not relative paths. >> 'C:/Python27/my_Djando_ >> projects/mysite/My_Templates/**admin/base_site.html', >> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/** >> admin/index.html', >> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/'**, >> ) >> > > No, this is *not* correct. It may work, but that's because the first two > will simply not be found. > > You *only* need the last line here (including the comma). > -- > DR. > >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/xcPMN9h-SIgJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Sami Balbaky System Engineer - Ultrawave Labs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
On Friday, 2 March 2012 21:47:54 UTC, Django_for_SB wrote: > > Thank you everyone for your very insightful and helps remarks. I had 2 > issues with my code: > > 1) I didn't properly separate my directory strings with commas and > 2) I need to code the directory structure, and the absolute path to the > file itself. > > Here is the correct code from within settings.py: > > TEMPLATE_DIRS = ( > # Put strings here, like "/home/html/django_templates" or > "C:/www/django/templates". > # Always use forward slashes, even on Windows. > # Don't forget to use absolute paths, not relative paths. > 'C:/Python27/my_Djando_ > projects/mysite/My_Templates/admin/base_site.html', > 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/index.html', > 'C:/Python27/my_Djando_projects/mysite/My_Templates/', > ) > No, this is *not* correct. It may work, but that's because the first two will simply not be found. You *only* need the last line here (including the comma). -- DR. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/xcPMN9h-SIgJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
Thank you everyone for your very insightful and helps remarks. I had 2 issues with my code: 1) I didn't properly separate my directory strings with commas and 2) I need to code the directory structure, and the absolute path to the file itself. Here is the correct code from within settings.py: TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. 'C:/Python27/my_Djando_ projects/mysite/My_Templates/admin/base_site.html', 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/index.html', 'C:/Python27/my_Djando_projects/mysite/My_Templates/', ) On Thu, Mar 1, 2012 at 3:42 PM, Python_Junkiewrote: > > > On Wednesday, February 29, 2012 2:46:11 PM UTC-5, Django_for_SB wrote: >> >> Hello All, >> >> I'm going through the tutorial on djangoproject.com, and can't seem to >> hurdle over this section that reads "Write views that actually do >> something" >> >> Here's the code I have so far, which is directly copied from the >> tutorial or prescribed by the tutorial: >> >> views.py: >> "from django.template import Context, loader >> from polls.models import Poll >> from django.http import HttpResponse >> >> def index(request): >> latest_poll_list = Poll.objects.all().order_by('-**pub_date')[:5] >> t = loader.get_template('polls/**index.html') >> c = Context({ >> 'latest_poll_list': latest_poll_list, >> }) >> return HttpResponse(t.render(c))" >> >> >> >> settings.py: >> "... >> TEMPLATE_DIRS = ( >> # Put strings here, like "/home/html/django_templates" or "C:/www/ >> django/templates". >> # Always use forward slashes, even on Windows. >> # Don't forget to use absolute paths, not relative paths. >> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**admin/ >> base_site.html' >> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**admin/ >> index.html' >> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**polls/ >> index.html' >> ) >> ..." >> >> >> index.html: >> "{% if latest_poll_list %} >> >> {% for poll in latest_poll_list %} >> {{ poll.question }}> li> >> {% endfor %} >> >> {% else %} >> No polls are available. >> {% endif %} >> " >> >> >> >> >> I keep getting the same error, which reads: >> >> >> TemplateDoesNotExist at /polls/ >> >> polls/index.html >> >> Request Method: GET >> Request URL: http://localhost:8000/polls/ >> Django Version: 1.3.1 >> Exception Type: TemplateDoesNotExist >> Exception Value: >> >> polls/index.html >> >> Exception Location: C:\Python27\lib\site-**packages\django\template >> >> \loader.py in find_template, line 138 >> Python Executable: C:\Python27\python.exe >> Python Version: 2.7.2 >> Python Path: >> >> ['C:\\Python27\\my_Djando_**projects\\mysite', >> 'C:\\Windows\\system32\\**python27.zip', >> 'C:\\Python27\\DLLs', >> 'C:\\Python27\\lib', >> 'C:\\Python27\\lib\\plat-win'**, >> 'C:\\Python27\\lib\\lib-tk', >> 'C:\\Python27', >> 'C:\\Python27\\lib\\site-**packages'] >> >> Server time: Wed, 29 Feb 2012 11:32:54 -0800 >> Template-loader postmortem >> >> Django tried loading these templates, in this order: >> >> Using loader django.template.loaders.**filesystem.Loader: >> c:\python27\my_djando_**projects\mysite\my_templates\**admin >> \base_site.html >> c:\python27\my_djando_**projects\mysite\my_templates\**admin\index.html >> c:\python27\my_djando_**projects\mysite\my_templates\**polls\index.html >> \polls\index.html (File does not exist) >> Using loader django.template.loaders.app_**directories.Loader: >> c:\python27\lib\site-packages\**django\contrib\admin\**templates\polls >> \index.html (File does not exist) >> >> >> >> >> What on earth am I doing wrong here? I've so many different variations >> of my settings.py, views.py, and index.html. Any help would be much >> appreciated. >> >> >> Thanks, >> >> SB >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/klXbEFxYWH4J. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Sami Balbaky System Engineer - Ultrawave Labs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
On Wednesday, February 29, 2012 2:46:11 PM UTC-5, Django_for_SB wrote: > > Hello All, > > I'm going through the tutorial on djangoproject.com, and can't seem to > hurdle over this section that reads "Write views that actually do > something" > > Here's the code I have so far, which is directly copied from the > tutorial or prescribed by the tutorial: > > views.py: > "from django.template import Context, loader > from polls.models import Poll > from django.http import HttpResponse > > def index(request): > latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] > t = loader.get_template('polls/index.html') > c = Context({ > 'latest_poll_list': latest_poll_list, > }) > return HttpResponse(t.render(c))" > > > > settings.py: > "... > TEMPLATE_DIRS = ( > # Put strings here, like "/home/html/django_templates" or "C:/www/ > django/templates". > # Always use forward slashes, even on Windows. > # Don't forget to use absolute paths, not relative paths. > 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ > base_site.html' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ > index.html' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ > index.html' > ) > ..." > > > index.html: > "{% if latest_poll_list %} > > {% for poll in latest_poll_list %} > {{ poll.question }} li> > {% endfor %} > > {% else %} > No polls are available. > {% endif %} > " > > > > > I keep getting the same error, which reads: > > > TemplateDoesNotExist at /polls/ > > polls/index.html > > Request Method: GET > Request URL: http://localhost:8000/polls/ > Django Version: 1.3.1 > Exception Type: TemplateDoesNotExist > Exception Value: > > polls/index.html > > Exception Location: C:\Python27\lib\site-packages\django\template > \loader.py in find_template, line 138 > Python Executable: C:\Python27\python.exe > Python Version: 2.7.2 > Python Path: > > ['C:\\Python27\\my_Djando_projects\\mysite', > 'C:\\Windows\\system32\\python27.zip', > 'C:\\Python27\\DLLs', > 'C:\\Python27\\lib', > 'C:\\Python27\\lib\\plat-win', > 'C:\\Python27\\lib\\lib-tk', > 'C:\\Python27', > 'C:\\Python27\\lib\\site-packages'] > > Server time: Wed, 29 Feb 2012 11:32:54 -0800 > Template-loader postmortem > > Django tried loading these templates, in this order: > > Using loader django.template.loaders.filesystem.Loader: > c:\python27\my_djando_projects\mysite\my_templates\admin > \base_site.html > c:\python27\my_djando_projects\mysite\my_templates\admin\index.html > c:\python27\my_djando_projects\mysite\my_templates\polls\index.html > \polls\index.html (File does not exist) > Using loader django.template.loaders.app_directories.Loader: > c:\python27\lib\site-packages\django\contrib\admin\templates\polls > \index.html (File does not exist) > > > > > What on earth am I doing wrong here? I've so many different variations > of my settings.py, views.py, and index.html. Any help would be much > appreciated. > > > Thanks, > > SB > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/klXbEFxYWH4J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
Just to get you past the error and display your data, I suggest hard coding the directory path in your view. The work your way backwards to the settings file try t = loader.get_template('C:\\Python27\\my_Djando_projects\\mysite\\My_Templates\\polls\\index.html'') You could also add a little bit of python into your view to list the directory and print out the variable in the template just for a sanity check path=C:\\Python27\\my_Djando_projects\\mysite\\My_Templates\\polls\\' var=os.lisdir(path) c = Context({ 'latest_poll_list': latest_poll_list,"var":var, }) and then add the dictionary value {{var}} in your template On Wednesday, February 29, 2012 2:48:53 PM UTC-5, atm wrote: > > You have to give template directories, not template names in the > settings.py. > Thanks, > Anoop > atm > ___ > Life is short, Live it hard. > > > > > On 1 March 2012 01:16, Django_for_SBwrote: > >> Hello All, >> >> I'm going through the tutorial on djangoproject.com, and can't seem to >> hurdle over this section that reads "Write views that actually do >> something" >> >> Here's the code I have so far, which is directly copied from the >> tutorial or prescribed by the tutorial: >> >> views.py: >> "from django.template import Context, loader >> from polls.models import Poll >> from django.http import HttpResponse >> >> def index(request): >>latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] >>t = loader.get_template('polls/index.html') >>c = Context({ >>'latest_poll_list': latest_poll_list, >>}) >>return HttpResponse(t.render(c))" >> >> >> >> settings.py: >> "... >> TEMPLATE_DIRS = ( >># Put strings here, like "/home/html/django_templates" or "C:/www/ >> django/templates". >># Always use forward slashes, even on Windows. >># Don't forget to use absolute paths, not relative paths. >>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >> base_site.html' >>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >> index.html' >>'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ >> index.html' >> ) >> ..." >> >> >> index.html: >> "{% if latest_poll_list %} >> >>{% for poll in latest_poll_list %} >>{{ poll.question }}> li> >>{% endfor %} >> >> {% else %} >>No polls are available. >> {% endif %} >> " >> >> >> >> >> I keep getting the same error, which reads: >> >> >> TemplateDoesNotExist at /polls/ >> >> polls/index.html >> >> Request Method: GET >> Request URL:http://localhost:8000/polls/ >> Django Version: 1.3.1 >> Exception Type: TemplateDoesNotExist >> Exception Value: >> >> polls/index.html >> >> Exception Location: C:\Python27\lib\site-packages\django\template >> \loader.py in find_template, line 138 >> Python Executable: C:\Python27\python.exe >> Python Version: 2.7.2 >> Python Path: >> >> ['C:\\Python27\\my_Djando_projects\\mysite', >> 'C:\\Windows\\system32\\python27.zip', >> 'C:\\Python27\\DLLs', >> 'C:\\Python27\\lib', >> 'C:\\Python27\\lib\\plat-win', >> 'C:\\Python27\\lib\\lib-tk', >> 'C:\\Python27', >> 'C:\\Python27\\lib\\site-packages'] >> >> Server time:Wed, 29 Feb 2012 11:32:54 -0800 >> Template-loader postmortem >> >> Django tried loading these templates, in this order: >> >> Using loader django.template.loaders.filesystem.Loader: >> c:\python27\my_djando_projects\mysite\my_templates\admin >> \base_site.html >> c:\python27\my_djando_projects\mysite\my_templates\admin\index.html >> c:\python27\my_djando_projects\mysite\my_templates\polls\index.html >> \polls\index.html (File does not exist) >> Using loader django.template.loaders.app_directories.Loader: >> c:\python27\lib\site-packages\django\contrib\admin\templates\polls >> \index.html (File does not exist) >> >> >> >> >> What on earth am I doing wrong here? I've so many different variations >> of my settings.py, views.py, and index.html. Any help would be much >> appreciated. >> >> >> Thanks, >> >> SB >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/7pKyULz9dxYJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
On Wednesday, 29 February 2012 20:03:21 UTC, Django_for_SB wrote: > > Hi Anoop, > > Thank you for the kind reply, I've tried that already. Here are the 3 > variations that I've attempted so far within settings.py in TEMPLATE_DIRS: > > 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/' > > > They all yield the same error unfortunately. I'm coding this on a Windows > Vista system, fyi. > > Best, > > SB > > On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathew wrote: > >> You have to give template directories, not template names in the >> settings.py. >> Thanks, >> Anoop >> atm >> ___ >> Life is short, Live it hard. >> >> You also need to separate the different strings with commas. Otherwise Python will automatically concatenate them, as they are within parentheses. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/mDeB71nwRSUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
Try: 'C:\Python27\my_Djando_projects\mysite\My_Templates\polls\index.html' 'C:\Python27\my_Djando_projects\mysite\My_Templates\polls\' 'C:\Python27\my_Djando_projects\mysite\My_Templates\' Or: abspath = lambda *p: os.path.abspath(os.path.join(*p)) PROJECT_ROOT = abspath(os.path.dirname(__file__)) (...) TEMPLATE_DIRS = (abspath(PROJECT_ROOT, "My_Templates"),) 2012/2/29 Sami Balbaky> Hi Anoop, > > Thank you for the kind reply, I've tried that already. Here are the 3 > variations that I've attempted so far within settings.py in TEMPLATE_DIRS: > > 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/' > 'C:/Python27/my_Djando_projects/mysite/My_Templates/' > > > They all yield the same error unfortunately. I'm coding this on a Windows > Vista system, fyi. > > Best, > > SB > > > On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathew wrote: > >> You have to give template directories, not template names in the >> settings.py. >> Thanks, >> Anoop >> atm >> ___ >> Life is short, Live it hard. >> >> >> >> >> >> On 1 March 2012 01:16, Django_for_SB wrote: >> >>> Hello All, >>> >>> I'm going through the tutorial on djangoproject.com, and can't seem to >>> hurdle over this section that reads "Write views that actually do >>> something" >>> >>> Here's the code I have so far, which is directly copied from the >>> tutorial or prescribed by the tutorial: >>> >>> views.py: >>> "from django.template import Context, loader >>> from polls.models import Poll >>> from django.http import HttpResponse >>> >>> def index(request): >>>latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] >>>t = loader.get_template('polls/index.html') >>>c = Context({ >>>'latest_poll_list': latest_poll_list, >>>}) >>>return HttpResponse(t.render(c))" >>> >>> >>> >>> settings.py: >>> "... >>> TEMPLATE_DIRS = ( >>># Put strings here, like "/home/html/django_templates" or "C:/www/ >>> django/templates". >>># Always use forward slashes, even on Windows. >>># Don't forget to use absolute paths, not relative paths. >>>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >>> base_site.html' >>>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >>> index.html' >>>'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ >>> index.html' >>> ) >>> ..." >>> >>> >>> index.html: >>> "{% if latest_poll_list %} >>> >>>{% for poll in latest_poll_list %} >>>{{ poll.question }}>> li> >>>{% endfor %} >>> >>> {% else %} >>>No polls are available. >>> {% endif %} >>> " >>> >>> >>> >>> >>> I keep getting the same error, which reads: >>> >>> >>> TemplateDoesNotExist at /polls/ >>> >>> polls/index.html >>> >>> Request Method: GET >>> Request URL:http://localhost:8000/polls/ >>> Django Version: 1.3.1 >>> Exception Type: TemplateDoesNotExist >>> Exception Value: >>> >>> polls/index.html >>> >>> Exception Location: C:\Python27\lib\site-packages\django\template >>> \loader.py in find_template, line 138 >>> Python Executable: C:\Python27\python.exe >>> Python Version: 2.7.2 >>> Python Path: >>> >>> ['C:\\Python27\\my_Djando_projects\\mysite', >>> 'C:\\Windows\\system32\\python27.zip', >>> 'C:\\Python27\\DLLs', >>> 'C:\\Python27\\lib', >>> 'C:\\Python27\\lib\\plat-win', >>> 'C:\\Python27\\lib\\lib-tk', >>> 'C:\\Python27', >>> 'C:\\Python27\\lib\\site-packages'] >>> >>> Server time:Wed, 29 Feb 2012 11:32:54 -0800 >>> Template-loader postmortem >>> >>> Django tried loading these templates, in this order: >>> >>> Using loader django.template.loaders.filesystem.Loader: >>> c:\python27\my_djando_projects\mysite\my_templates\admin >>> \base_site.html >>> c:\python27\my_djando_projects\mysite\my_templates\admin\index.html >>> c:\python27\my_djando_projects\mysite\my_templates\polls\index.html >>> \polls\index.html (File does not exist) >>> Using loader django.template.loaders.app_directories.Loader: >>> c:\python27\lib\site-packages\django\contrib\admin\templates\polls >>> \index.html (File does not exist) >>> >>> >>> >>> >>> What on earth am I doing wrong here? I've so many different variations >>> of my settings.py, views.py, and index.html. Any help would be much >>> appreciated. >>> >>> >>> Thanks, >>> >>> SB >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
Hi Anoop, Thank you for the kind reply, I've tried that already. Here are the 3 variations that I've attempted so far within settings.py in TEMPLATE_DIRS: 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html' 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/' 'C:/Python27/my_Djando_projects/mysite/My_Templates/' They all yield the same error unfortunately. I'm coding this on a Windows Vista system, fyi. Best, SB On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathewwrote: > You have to give template directories, not template names in the > settings.py. > Thanks, > Anoop > atm > ___ > Life is short, Live it hard. > > > > > > On 1 March 2012 01:16, Django_for_SB wrote: > >> Hello All, >> >> I'm going through the tutorial on djangoproject.com, and can't seem to >> hurdle over this section that reads "Write views that actually do >> something" >> >> Here's the code I have so far, which is directly copied from the >> tutorial or prescribed by the tutorial: >> >> views.py: >> "from django.template import Context, loader >> from polls.models import Poll >> from django.http import HttpResponse >> >> def index(request): >>latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] >>t = loader.get_template('polls/index.html') >>c = Context({ >>'latest_poll_list': latest_poll_list, >>}) >>return HttpResponse(t.render(c))" >> >> >> >> settings.py: >> "... >> TEMPLATE_DIRS = ( >># Put strings here, like "/home/html/django_templates" or "C:/www/ >> django/templates". >># Always use forward slashes, even on Windows. >># Don't forget to use absolute paths, not relative paths. >>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >> base_site.html' >>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ >> index.html' >>'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ >> index.html' >> ) >> ..." >> >> >> index.html: >> "{% if latest_poll_list %} >> >>{% for poll in latest_poll_list %} >>{{ poll.question }}> li> >>{% endfor %} >> >> {% else %} >>No polls are available. >> {% endif %} >> " >> >> >> >> >> I keep getting the same error, which reads: >> >> >> TemplateDoesNotExist at /polls/ >> >> polls/index.html >> >> Request Method: GET >> Request URL:http://localhost:8000/polls/ >> Django Version: 1.3.1 >> Exception Type: TemplateDoesNotExist >> Exception Value: >> >> polls/index.html >> >> Exception Location: C:\Python27\lib\site-packages\django\template >> \loader.py in find_template, line 138 >> Python Executable: C:\Python27\python.exe >> Python Version: 2.7.2 >> Python Path: >> >> ['C:\\Python27\\my_Djando_projects\\mysite', >> 'C:\\Windows\\system32\\python27.zip', >> 'C:\\Python27\\DLLs', >> 'C:\\Python27\\lib', >> 'C:\\Python27\\lib\\plat-win', >> 'C:\\Python27\\lib\\lib-tk', >> 'C:\\Python27', >> 'C:\\Python27\\lib\\site-packages'] >> >> Server time:Wed, 29 Feb 2012 11:32:54 -0800 >> Template-loader postmortem >> >> Django tried loading these templates, in this order: >> >> Using loader django.template.loaders.filesystem.Loader: >> c:\python27\my_djando_projects\mysite\my_templates\admin >> \base_site.html >> c:\python27\my_djando_projects\mysite\my_templates\admin\index.html >> c:\python27\my_djando_projects\mysite\my_templates\polls\index.html >> \polls\index.html (File does not exist) >> Using loader django.template.loaders.app_directories.Loader: >> c:\python27\lib\site-packages\django\contrib\admin\templates\polls >> \index.html (File does not exist) >> >> >> >> >> What on earth am I doing wrong here? I've so many different variations >> of my settings.py, views.py, and index.html. Any help would be much >> appreciated. >> >> >> Thanks, >> >> SB >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Sami Balbaky System Engineer - Ultrawave Labs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at
Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/
You have to give template directories, not template names in the settings.py. Thanks, Anoop atm ___ Life is short, Live it hard. On 1 March 2012 01:16, Django_for_SBwrote: > Hello All, > > I'm going through the tutorial on djangoproject.com, and can't seem to > hurdle over this section that reads "Write views that actually do > something" > > Here's the code I have so far, which is directly copied from the > tutorial or prescribed by the tutorial: > > views.py: > "from django.template import Context, loader > from polls.models import Poll > from django.http import HttpResponse > > def index(request): >latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] >t = loader.get_template('polls/index.html') >c = Context({ >'latest_poll_list': latest_poll_list, >}) >return HttpResponse(t.render(c))" > > > > settings.py: > "... > TEMPLATE_DIRS = ( ># Put strings here, like "/home/html/django_templates" or "C:/www/ > django/templates". ># Always use forward slashes, even on Windows. ># Don't forget to use absolute paths, not relative paths. >'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ > base_site.html' >'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ > index.html' >'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ > index.html' > ) > ..." > > > index.html: > "{% if latest_poll_list %} > >{% for poll in latest_poll_list %} >{{ poll.question }} li> >{% endfor %} > > {% else %} >No polls are available. > {% endif %} > " > > > > > I keep getting the same error, which reads: > > > TemplateDoesNotExist at /polls/ > > polls/index.html > > Request Method: GET > Request URL:http://localhost:8000/polls/ > Django Version: 1.3.1 > Exception Type: TemplateDoesNotExist > Exception Value: > > polls/index.html > > Exception Location: C:\Python27\lib\site-packages\django\template > \loader.py in find_template, line 138 > Python Executable: C:\Python27\python.exe > Python Version: 2.7.2 > Python Path: > > ['C:\\Python27\\my_Djando_projects\\mysite', > 'C:\\Windows\\system32\\python27.zip', > 'C:\\Python27\\DLLs', > 'C:\\Python27\\lib', > 'C:\\Python27\\lib\\plat-win', > 'C:\\Python27\\lib\\lib-tk', > 'C:\\Python27', > 'C:\\Python27\\lib\\site-packages'] > > Server time:Wed, 29 Feb 2012 11:32:54 -0800 > Template-loader postmortem > > Django tried loading these templates, in this order: > > Using loader django.template.loaders.filesystem.Loader: > c:\python27\my_djando_projects\mysite\my_templates\admin > \base_site.html > c:\python27\my_djando_projects\mysite\my_templates\admin\index.html > c:\python27\my_djando_projects\mysite\my_templates\polls\index.html > \polls\index.html (File does not exist) > Using loader django.template.loaders.app_directories.Loader: > c:\python27\lib\site-packages\django\contrib\admin\templates\polls > \index.html (File does not exist) > > > > > What on earth am I doing wrong here? I've so many different variations > of my settings.py, views.py, and index.html. Any help would be much > appreciated. > > > Thanks, > > SB > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.