Thanks for all the help, I've learned a lot!  I was able to figure out why
the last two wouldn't resolve.  The url part /(?P<slug>[-w]+)/$ should be /
(?P<slug>[-*\*w]+)/$ that way it looks for all words instead of w's with
-'s. I fixed that and it now works.  Once again thanks for all the help, I
have included the working main urls.py and blog urls.py.

Antti

*main urls.py*

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^anttipetaisto/', include('anttipetaisto.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
     (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     (r'^admin/', include(admin.site.urls)),
     (r'^tags/(?P<slug>[a-zA-Z0-9_.-]+)/$',
'anttipetaisto.tag_views.tag_detail'),
     (r'^blog/', include('anttipetaisto.blog.urls')),
     (r'^static_files/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/home/antti/django/anttipetaisto/static_files'}),
)


*blog urls.py*

from django.conf.urls.defaults import *
from anttipetaisto.blog.models import Entry
from tagging.views import tagged_object_list

info_dict = {
        'queryset': Entry.objects.filter(status=1),
        'date_field': 'pub_date',
}

urlpatterns = patterns('django.views.generic.date_based',

(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
'object_detail', dict(info_dict, slug_field='slug',
template_name='blog/detail.html')),

(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
'object_detail', dict(info_dict, template_name='blog/list.html')),

(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$','archive_day',dict(info_dict,template_name='blog/list.html')),
     (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$','archive_month',
dict(info_dict, template_name='blog/list.html')),
     (r'^(?P<year>\d{4})/$','archive_year', dict(info_dict,
template_name='blog/list.html')),
     (r'^$','archive_index', dict(info_dict,
template_name='blog/list.html')),
)


















(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-w]+)/$',
'object_detail', dict(info_dict, slug_field='slug',
template_name='blog/detail.html')),

(r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-w]+)/$',
'object_detail', dict(info_dict, template_name='blog/list.html')),

Before only


(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-w]+)/$',
'object_detail', dict(info_dict, slug_field='slug',
template_name='blog/detail.html')),

(r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-w]+)/$',
'object_detail', dict(info_dict, template_name='blog/list.html')),


On Tue, Feb 22, 2011 at 11:03 PM, Chris Matthews <ch...@bbd.co.za> wrote:

>  Hi Antti,
>
>
>
> 1) Your day match is for \w{1,2} which will match one or 2 digits but also
> word characters because \w is same as [a-zA-Z0-9_] (see re documentation).
>
>
>
> (r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$'
>
> Should be
>
> (r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<slug>[-w]+)/$'
>
>
>
> 2) The slash before the [ is wrong. See
> http://docs.python.org/library/re.html [] is used to match a set/range of
> characters.
>
>  (?P<month>\[a-z]{3})"
>
>
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\w
> {1,2})/(?P<slug>\[-w]+)/$',
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\w{1,2})/$',
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/$',
>
>
>
> 3) The list.html is shown because it matches:
>
> (r'^blog/', include('anttipetaisto.blog.urls')),
>
> and then
>
> (r'^$','archive_index', dict(info_dict, template_name='blog/list.html')),
>
>
>
>
>
> What URL do you enter when you get the error?
>
>
>
> Regards
>
> Chris
>
>
>
> -----Original Message-----
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Antti
>
> Sent: 23 February 2011 06:56
>
> To: Django users
>
> Subject: Re: urls.py and views.generic issue
>
>
>
> Thanks jnns for the response.  I tried adding the backslash but it
>
> still doesn't match. Would I need to put a different character after
>
> the other entries in the expression? What I mean would there be a
>
> different character used in "(?P<month>\[a-z]{3})" ?  Also one more
>
> note if I type in http://127.0.0.1:8000/blog/ then the page loads
>
> using the list.html template as it should.   I have included the main
>
> urls.py as well as the blog urls.py
>
>
>
> -----Original Message-----
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Antti
> Sent: 23 February 2011 06:48
> To: Django users
> Subject: Re: urls.py and views.generic issue
>
>
>
> Hello Chris, thanks for the response. I don't know where that space is
>
> coming from.  When I type in http://127.0.0.1:8000/blog/ a page loads
>
> using the list.html template as it should. Would that mean that the
>
> space might be fine because the main urls.py is calling the blog
>
> urls.py?
>
>
>
> I have a main urls.py and then I have a blog urls.py. The files are as
>
> below and the space is added somewhere along the lines.
>
>
>
> Main urls.py
>
>
>
> from django.conf.urls.defaults import *
>
>
>
> # Uncomment the next two lines to enable the admin:
>
> from django.contrib import admin
>
>
>
> admin.autodiscover()
>
>
>
> urlpatterns = patterns('',
>
>     # Example:
>
>     # (r'^anttipetaisto/', include('anttipetaisto.foo.urls')),
>
>
>
>     # Uncomment the admin/doc line below to enable admin
>
> documentation:
>
>      (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>
>
>     # Uncomment the next line to enable the admin:
>
>      (r'^admin/', include(admin.site.urls)),
>
>      (r'^tags/(?P<slug>[a-zA-Z0-9_.-]+)/$',
>
> 'anttipetaisto.tag_views.tag_detail'),
>
>      (r'^blog/', include('anttipetaisto.blog.urls')),
>
>      (r'^static_files/(?P<path>.*)$', 'django.views.static.serve',
>
> {'document_root': '/home/antti/django/anttipetaisto/static_files'}),
>
>
>
>
>
> Blog urls.py
>
>
>
> from django.conf.urls.defaults import *
>
> from anttipetaisto.blog.models import Entry
>
> from tagging.views import tagged_object_list
>
>
>
> info_dict = {
>
>         'queryset': Entry.objects.filter(status=1),
>
>         'date_field': 'pub_date',
>
> }
>
>
>
> urlpatterns = patterns('django.views.generic.date_based',
>
>      (r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-
>
> w]+)/$', 'object_detail', dict(info_dict, slug_field='slug',
>
> template_name='blog/detail.html')),
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\w{1,2})/(?
>
> P<slug>\[-w]+)/$', 'object_detail', dict(info_dict,
>
> template_name='blog/list.html')),
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/(?P<day>\w{1,2})/
>
> $','archive_day',dict(info_dict,template_name='blog/list.html')),
>
>      (r'^(?P<year>\d{4})/(?P<month>\[a-z]{3})/$','archive_month',
>
> dict(info_dict, template_name='blog/list.html')),
>
>      (r'^(?P<year>\d{4})/$','archive_year', dict(info_dict,
>
> template_name='blog/list.html')),
>
>      (r'^$','archive_index', dict(info_dict, template_name='blog/
>
> list.html')),
>
> )
>
>
>
> On Feb 20, 10:47 pm, Chris Matthews <ch...@bbd.co.za> wrote:
>
> > It also seems that the space preceding the caret ^ should not be there
>
> >
>
> > So
>
> >
>
> > ^blog/ ^(?P<year>\d{4})/$
>
> >
>
> > Should be
>
> >
>
> > ^blog/^(?P<year>\d{4})/$
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > -----Original Message-----
>
> > From: django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] On Behalf Of jnns
>
> > Sent: 20 February 2011 03:07
>
> > To: Django users
>
> > Subject: Re: urls.py and views.generic issue
>
> >
>
> > Hi Antti,
>
> >
>
> > the url patterns in the tutorial are not correct. The regular
>
> >
>
> > expressions are not using character classes but merely plain
>
> >
>
> > characters.
>
> >
>
> > ^blog/ ^(?P<year>d{4})/$
>
> >
>
> > should be
>
> >
>
> > ^blog/ ^(?P<year>\d{4})/$
>
> >
>
> > Mind the backslash in \d{4}. This way we're matching for a sequence of
>
> >
>
> > four digits and not for a sequence of four "d"s.
>
> >
>
> > Regards,
>
> >
>
> > jnns
>
> >
>
> > On Feb 20, 12:57 am, Antti <ahpetai...@gmail.com> wrote:
>
> >
>
> > > The problem:
>
> >
>
> > > I can't seem to get most of my urls that I type in my browser to math
>
> >
>
> > > a url in my urls.py file.  I am currently doing Web Monkey's Blog
>
> >
>
> > > Tutorial (http://www.webmonkey.com/2010/02/Get_Started_With_Django/)
>
> >
>
> > > To date everything has worked but when I try to use the urls from the
>
> >
>
> > > blog urls.py I get the following error:
>
> >
>
> > > Using the URLconf defined in anttipetaisto.urls, Django tried these
>
> >
>
> > > URL patterns, in this order:
>
> >
>
> > > ^admin/doc/
>
> >
>
> > > ^admin/
>
> >
>
> > > ^blog/ (?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]
>
> >
>
> > > +)/$
>
> >
>
> > > ^blog/ ^(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-
>
> >
>
> > > w]+)/$
>
> >
>
> > > ^blog/ ^(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/$
>
> >
>
> > > ^blog/ ^(?P<year>d{4})/(?P<month>[a-z]{3})/$
>
> >
>
> > > ^blog/ ^(?P<year>d{4})/$
>
> >
>
> > > ^blog/ ^$
>
> >
>
> > > ^tags/(?P<slug>[a-zA-Z0-9_.-]+)/$
>
> >
>
> > > ^static_files/(?P<path>.*)$
>
> >
>
> > > The current URL, blog/2011/jan/20/things-learned-finland/, didn't
>
> >
>
> > > match any of these.
>
> >
>
> > > What I don't understand why this is saying that isn't a url match.
>
> >
>
> > > Shouldn't it match the third one down?
>
> >
>
> > > Thanks
>
> >
>
> > > Antti
>
> >
>
> > --
>
> >
>
> > 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 athttp://
> 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.
>
>
>
> --
> 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.
>



-- 
Antti Petaisto
ahpetai...@gmail.com

-- 
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.

Reply via email to