Re: 'str' object is not callable

2009-08-03 Thread Dolph

hey Ronghui,

Thanks for the reply. I couldnt get your first suggestion to work, I
get "name 'coltrane_category_detail' is not defined". Also,

Also, I never posted my models.py in my Category class,
get_absolute_url:

def get_absolute_url(self):
return ('coltrane_category_detail', (), {'slug': self.slug})

Perhaps I'm doing something wrong here? Could it be the way that I'm
passing the values?

On Aug 2, 7:44 pm, Ronghui Yu <stone...@gmail.com> wrote:
> Try to configure url from
> (r'^(?P[-\w]+)/$', 'coltrane_category_detail'),
>
> to
>
> (r'^(?P[-\w]+)/$', coltrane_category_detail),
>
> But before that, you need to import this function
>
> Or
>
> give a whole path to the view like
>
> (r'^(?P[-\w]+)/$', 'pack_xxx.mod_xxx.coltrane_category_detail'),
>
>
>
> On Mon, Aug 3, 2009 at 2:00 AM, Dolph <ekinsko...@gmail.com> wrote:
>
> > hey guys,
>
> > New to django and I'm just working through James Bennett's practical
> > django projects book, 2nd ed. I'm trying to get the categories section
> > working in the blog and I'm getting the above error. I've read through
> > some of the previous posts to try to figure it out, but I can't seem
> > to figure it out.
>
> > error:
>
> > /usr/lib/python2.5/site-packages/django/core/handlers/base.py in
> > get_response, line 86
>
> > categories.py in urls directory:
>
> > from django.conf.urls.defaults import *
>
> > from coltrane.models import Category
>
> > urlpatterns = patterns('',
> >        (r'^$','django.views.generic.list_detail.object_list',
> >            { 'queryset': Category.objects.all() }),
> >        (r'^(?P[-\w]+)/$', 'coltrane_category_detail'),
> > )
>
> > here's my view in coltrane:
>
> > from django.shortcuts import get_object_or_404
> > from coltrane.models import Category
> > from django.views.generic.list_detail import object_list
>
> > def category_detail(request, slug):
> >    category = get_object_or_404(Category, slug=slug)
> >    return object_list(request, queryset=category.entry_set.all(),
> >            extra_context={ 'category': category })
>
> > the category list works ok and the get_absolute_url is rendering the
> > correct link, but when I click on the link or attempt to get specific
> > category details, i.e. "http://127.0.0.1:8000/weblog/categories/
> > programming/", I get the above error.
>
> > thanks.
>
> > Eric
>
> --
> ===
> Regards
> Ronghui Yu
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



'str' object is not callable

2009-08-02 Thread Dolph

hey guys,

New to django and I'm just working through James Bennett's practical
django projects book, 2nd ed. I'm trying to get the categories section
working in the blog and I'm getting the above error. I've read through
some of the previous posts to try to figure it out, but I can't seem
to figure it out.

error:

/usr/lib/python2.5/site-packages/django/core/handlers/base.py in
get_response, line 86

categories.py in urls directory:

from django.conf.urls.defaults import *

from coltrane.models import Category

urlpatterns = patterns('',
(r'^$','django.views.generic.list_detail.object_list',
{ 'queryset': Category.objects.all() }),
(r'^(?P[-\w]+)/$', 'coltrane_category_detail'),
)

here's my view in coltrane:

from django.shortcuts import get_object_or_404
from coltrane.models import Category
from django.views.generic.list_detail import object_list

def category_detail(request, slug):
category = get_object_or_404(Category, slug=slug)
return object_list(request, queryset=category.entry_set.all(),
extra_context={ 'category': category })

the category list works ok and the get_absolute_url is rendering the
correct link, but when I click on the link or attempt to get specific
category details, i.e. "http://127.0.0.1:8000/weblog/categories/
programming/", I get the above error.

thanks.

Eric

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