Thank you Malcolm and Karen, I had to step for the day but when I got
home I read your comments and fixed the issue which was exactly as you
both pointed out.

this helped make my photo model much more search friendly.

    @permalink
    def get_absolute_url(self):
        return ('photo_detail',  None, { 'state' :
self.place.city.state.slug , 'city' : self.place.city.slug, 'place' :
self.place.slug, 'slug': self.slug })

and in my views.py

    #photo
    url(r'^photo/(?P<state>[-\w]+)/(?P<city>[-\w]+)/(?P<place>[-\w]+)/
(?P<slug>[\-\d\w]+)/$',
      view = 'photologue.views.photo_detail',
      name = 'photo_detail',
    ),


On Apr 24, 11:43 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Apr 24, 2008 at 12:21 PM, Merrick <[EMAIL PROTECTED]> wrote:
>
> > Thank you, I updated get_absolute_url to take into consideration the
> > fact that I was erroneously using state_slug instead of state.slug and
> > the same with photo.slug and place.slug
>
> >    def get_absolute_url(self):
> >        return ('photo-detail',  None, { 'state' :
> > self.photo.place.city.state.slug , 'city' :
> > self.photo.place.city.slug, 'place' : self.photo.place.slug, 'slug':
> > self.slug })
>
> > >>> from photologue.models import *
> > >>> photo = Photo.objects.get(slug='golf-course-3')
> > >>> photo.get_absolute_url()
>
> > still getting this error:
>
> > AttributeError: 'RelatedManager' object has no attribute 'place'
>
> As Malcolm said, within get_absolute_url, self is already the Photo
> instance, so it is confusing what you are trying to get at when you use
> 'self.photo' here.  In fact given the models you have defined, self.photo is
> referencing the model manager for the set of Gallery instances that have
> self as 'featured_photo'.  (I think you might want to rethink that
> related_name specification, since it seems to be confusing enough to have
> tripped you up here.)
>
> Within get_absolute_url, to refer to the photo instance, just use self, not
> self.photo.  When you fix that you are going to hit an error because the
> Place model does not have a slug field, and yet you are trying to access it
> when you code self.place.slug.  I don't know what you are really intending
> to specify here.
>
> Karen
>
>
>
> > On Apr 24, 8:59 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
> > > On Thu, 2008-04-24 at 08:55 -0700, Merrick wrote:
>
> > > [...]
>
> > > > ***Shell output
>
> > > > >>> from photologue.models import *
> > > > >>> photo = Photo.objects.get(slug='golf-course-3')
> > > > >>> photo.place.city.state_slug
> > > > Traceback (most recent call last):
> > > >   File "<console>", line 1, in ?
> > > > AttributeError: 'City' object has no attribute 'state_slug'
>
> > > This is telling you exactly what the error is. You're accessing a
> > > non-existent attribute on the City model. Maybe you mean to state.slug
> > > instead of state_slug or maybe you mean something else there. In any
> > > case, there is no state_slug attribute.
>
> > > Malcolm
>
> > > --
> > > He who laughs last thinks slowest.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to