RE: Method to find the admin url for an object

2007-06-27 Thread Chris Brand
> If you're wanting it for actual inclusion, there's also the edge case > of whether the model's been saved. If not PK is None, and the URL > will be mal-formed. > > I dunno what to do for that corner case. I guess it might make sense to return the "add" url instead, although that makes it

Re: Method to find the admin url for an object

2007-06-27 Thread Jeremy Dunck
On 6/27/07, Chris Brand <[EMAIL PROTECTED]> wrote: ... > Hmmm. Nice, except that it hardcodes the base url of the admin, which leads > me to this : If you're wanting it for actual inclusion, there's also the edge case of whether the model's been saved. If not PK is None, and the URL will be

RE: Method to find the admin url for an object

2007-06-27 Thread Chris Brand
> Small tweak to support models which don't use AutoField for primary_key. > > def get_admin_url(self): >pk = getattr(self, self._meta.pk.attname) >return "/admin/%s/%s/%s/" % ( > self._meta.app_label, > self._meta.module_name, > pk) Hmmm. Nice, except that it

Re: Method to find the admin url for an object

2007-06-27 Thread Jeremy Dunck
On 6/27/07, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > > def get_admin_url(self): > return "%s/%s/%s/%s/" % ("/admin", self._meta.app_label, Small tweak to support models which don't use AutoField for primary_key. def get_admin_url(self): pk = getattr(self,

Re: Method to find the admin url for an object

2007-06-27 Thread Nathaniel Whiteinge
Not sure if this is what you're looking for, or if there's an official way to to this, but I'm using this:: def get_admin_url(self): return "%s/%s/%s/%s/" % ("/admin", self._meta.app_label, self._meta.object_name.lower(), self.id) Stolen from wamber.net. - whiteinge