Re: stuck with tutorial 3 at - Write views that actually do something
J. Clifford Dyer sdf.lonestar.org> writes: > > > On Fri, Dec 14, 2007 at 01:01:37PM -0800, haver wrote regarding stuck with tutorial 3 at - Write views that > actually do something: > > > > > > Hi All, > > > > I started with django and went through 2.5 tutorials relatively > > painless, but nevertheless I stuck on tutorial #3. I tried to modify > > regular expression, but error getting more complecated. > > help needed fixed the urls.py (my guess) > > thanks, > > > > Vadim Hi, I face the same problem as Vadim too when I followed the tutorial at (http://www.djangoproject.com/documentation/0.96/tutorial03/). I don't think we were supposed to change the URL config. Apparently the loader.get_template should have loaded index.html from the template directory, but it returned a 404 error for some reasons. Quoted from the site: "When youve done that, create a directory polls in your template directory. Within that, create a file called index.html. Note that our loader.get_template('polls/index.html') code from above maps to [template_directory]/polls/index.html on the filesystem." --Vincent --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: stuck with tutorial 3 at - Write views that actually do something
Hi, I face the same problem as haver too when I followed the tutorial at (http://www.djangoproject.com/documentation/0.96/tutorial03/). I don't think we were supposed to change the URL config. Apparently the loader.get_template should have loaded index.html from the template directory, but it returned a 404 error for some reasons. Quoted from the site: "When you've done that, create a directory polls in your template directory. Within that, create a file called index.html. Note that our loader.get_template('polls/index.html') code from above maps to "[template_directory]/polls/index.html" on the filesystem." --Vincent On Dec 15, 5:33 am, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > On Fri, Dec 14, 2007 at 01:01:37PM -0800, haver wrote regarding stuck with > tutorial 3 at - Write views that actually do something: > > > > > > > Hi All, > > > I started with django and went through 2.5 tutorials relatively > > painless, but nevertheless I stuck on tutorial #3. I tried to modify > > regular expression, but error getting more complecated. > > help needed fixed the urls.py (my guess) > > thanks, > > > Vadim > > > Error message: > > Request Method: GET > > Request URL:http://localhost:8000/polls/index.html > > > Using the URLconf defined in mysite.urls, Django tried these URL > > patterns, in this order: > > > ^polls/$ > > ^polls/(?P\d+)/$ > > ^polls/(?P\d+)/results/$ > > ^polls/(?P\d+)/vote/$ > > The current URL, polls/index.html, didn't match any of these. > > The $ means match the end of the url. So > > ^foo/$ > > means match a url that begins and ends with "foo/". > > Which of your URL regular expressions would you expect to match > polls/index.html? > > Assuming you want your index to show the list of polls, drop index.html from > the URL in your browser. If you need index.html there for legacy reasons, > change your urls.py file to include index.html before the $. For example: > > ^polls/index.html$ > > But then you won't match unless you have index.html in your URL, which is > probably even worse. > > If you aren't dealing with a legacy site, I would just drop the index.html. > It just makes your URLs uglier, and less accurate (because you aren't > actually serving up flat HTML). > > Cheers, > Cliff --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: stuck with tutorial 3 at - Write views that actually do something
On Fri, Dec 14, 2007 at 01:01:37PM -0800, haver wrote regarding stuck with tutorial 3 at - Write views that actually do something: > > > Hi All, > > I started with django and went through 2.5 tutorials relatively > painless, but nevertheless I stuck on tutorial #3. I tried to modify > regular expression, but error getting more complecated. > help needed fixed the urls.py (my guess) > thanks, > > Vadim > > Error message: > Request Method: GET > Request URL: http://localhost:8000/polls/index.html > > Using the URLconf defined in mysite.urls, Django tried these URL > patterns, in this order: > > ^polls/$ > ^polls/(?P\d+)/$ > ^polls/(?P\d+)/results/$ > ^polls/(?P\d+)/vote/$ > The current URL, polls/index.html, didn't match any of these. > The $ means match the end of the url. So ^foo/$ means match a url that begins and ends with "foo/". Which of your URL regular expressions would you expect to match polls/index.html? Assuming you want your index to show the list of polls, drop index.html from the URL in your browser. If you need index.html there for legacy reasons, change your urls.py file to include index.html before the $. For example: ^polls/index.html$ But then you won't match unless you have index.html in your URL, which is probably even worse. If you aren't dealing with a legacy site, I would just drop the index.html. It just makes your URLs uglier, and less accurate (because you aren't actually serving up flat HTML). Cheers, Cliff --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
stuck with tutorial 3 at - Write views that actually do something
Hi All, I started with django and went through 2.5 tutorials relatively painless, but nevertheless I stuck on tutorial #3. I tried to modify regular expression, but error getting more complecated. help needed fixed the urls.py (my guess) thanks, Vadim Error message: Request Method: GET Request URL: http://localhost:8000/polls/index.html Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^polls/$ ^polls/(?P\d+)/$ ^polls/(?P\d+)/results/$ ^polls/(?P\d+)/vote/$ The current URL, polls/index.html, didn't match any of these. == settings.py (partial view) ROOT_URLCONF = 'mysite.urls' TEMPLATE_DIRS = ( "C:/Python2/Script/mysite/mytemplates" ) =urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^polls/$', 'mysite.polls.views.index'), (r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'), (r'^polls/(?P\d+)/results/$', 'mysite.polls.views.results'), (r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'), ) views.py= from django.template import Context, loader from mysite.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)) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---