Hi group,

I'm working through this tutorial
http://www.webmonkey.com/2010/02/Use_URL_Patterns_and_Views_in_Django/

It's written for Django 1.0 and I'm using 1.3 which has changed to
class based views. I'm having a hard time converting from function
based to class based. Can anyone offer help on how to change the
following to class based views?

#urls.py

urlpatterns = patterns('',
              url(r'^admin/', include(admin.site.urls)),
        (r'^blog/', include('djangoblog.blog.urls')),
        (r'^tags/(?P<slug>[a-zA-Z0-9_.-]+)/$', 
'djangoblog.tag_views.tag_detail'),
)


#blog/urls.py
from django.conf.urls.defaults import *
from djangoblog.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')),
)

# views.py
from django.views.generic.list_detail import object_detail
from tagging.models import Tag,TaggedItem
from blog.models import Entry

def tag_detail(request, slug):
        unslug = slug.replace('-', ' ')
        tag = Tag.objects.get(name=unslug)
        qs = TaggedItem.objects.get_by_model(Entry, tag)
        return object_list(request, queryset=qs, extra_context={'tag':slug},
template_name='tags/detail.html')

Thanks!
- Jake

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