> 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
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
> 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
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,
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
In going through cleaning up all the hard-coded urls in my templates, I'm
making good use of the get_absolute_url methods that I've added to my
models.
Looking at the links I'm left with, they're almost all to the admin pages.
How would I write a method to provide a get_admin_change_url method ?
6 matches
Mail list logo