Re: get_absolute_url() and related models

2009-02-24 Thread Ben Davis
Thank you so much! It's funny because I had originally tried category__slug, not sure why it didn't occur to me to use self.category.slug ! Also, I'm glad to have learned about select_related() -- that's exactly what I was looking for! On Mon, Feb 23, 2009 at 6:36 PM, Malcolm Tredinnick < m

Re: get_absolute_url() and related models

2009-02-23 Thread Malcolm Tredinnick
On Tue, 2009-02-24 at 11:33 +1100, Malcolm Tredinnick wrote: [...] > You can certainly simplify get_absolute_url() a bit: > > def get_absolute_url(self): >category_slug = self.category__slug Sorry, this is a typo. Should be self.category.slug -- normal attribute reference stu

Re: get_absolute_url() and related models

2009-02-23 Thread Alex Gaynor
On Mon, Feb 23, 2009 at 7:33 PM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Mon, 2009-02-23 at 16:21 -0800, bendavis78 wrote: > > I have products within categories. The url for a product is /store/ > > category-slug/product-slug. My question is about the best way to get > > t

Re: get_absolute_url() and related models

2009-02-23 Thread Alex Gaynor
On Mon, Feb 23, 2009 at 7:21 PM, bendavis78 wrote: > > I have products within categories. The url for a product is /store/ > category-slug/product-slug. My question is about the best way to get > the url for this product while looping through a product listing > page. My view simply defines

Re: get_absolute_url() and related models

2009-02-23 Thread Malcolm Tredinnick
On Mon, 2009-02-23 at 16:21 -0800, bendavis78 wrote: > I have products within categories. The url for a product is /store/ > category-slug/product-slug. My question is about the best way to get > the url for this product while looping through a product listing > page. My view simply defines a

get_absolute_url() and related models

2009-02-23 Thread bendavis78
I have products within categories. The url for a product is /store/ category-slug/product-slug. My question is about the best way to get the url for this product while looping through a product listing page. My view simply defines a context variable called products, assigned to the results of