Aha! It has to do with #2.

I get an AttributeError that leads me to think I'm asking the wrong
question. So:

Is there a way to call a field from a related ForeignKey for one of
the attributes of get_absolute_url()?

That is:

class Thing(models.Model):
     slug = models.SlugField()

class OtherThing(models.Model):
     thing = models.ForeignKey(Thing)
     slug = models.SlugField()

     def get_absolute_url(self):
          return '/%s/%s/' % (self.thing.slug, self.slug)


On Aug 15, 2:42 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> I don't see anything wrong with what you have there. Try these:
>
> 1. Make sure the get_absolute_url method uses correct indentation (tab
> vs. 4 spaces) consistent with the rest of your models.py
>
> 2. Drop into a shell with "python manage.py shell" and get an instance
> of your model object. Then issue a direct obj.get_absolute_url() call
> on it to see why it might be failing.


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