Opened 8 years ago

Last modified 8 years ago

#27757 closed Bug

The link of the "view_on_site" button is not formed according to the returning result of the "get_absolute_url" method. — at Version 4

Reported by: George Tantiras Owned by: nobody
Component: contrib.admin Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by George Tantiras)

I am using Django-1.10.5 under Python-3.4.2.

from django.db import models


class Product(models.Model):
    name = models.CharField(verbose_name="Name", max_length=100, unique=True)

    def get_absolute_url(self):
        return "test-string/{0}".format(self.id)


class Flavor(models.Model):
    product = models.ForeignKey(Product, verbose_name="Product")
    name = models.CharField(verbose_name="Name", max_length=100)


    def get_absolute_url(self):
        return "test-string-2/{0}".format(self.id)

admin.py:

from django.contrib import admin
from inline_online.models import Flavor, Product


class FlavorInline(admin.TabularInline):
    model = Flavor


class ProductAdmin(admin.ModelAdmin):
    list_display = ("id", "name")
    inlines = [FlavorInline, ]


admin.site.register(Product, ProductAdmin)


class FlavorAdmin(admin.ModelAdmin):
    view_on_site = True


admin.site.register(Flavor, FlavorAdmin)

The view_on_site link appears either in the main model admin view or in the inlines but the url is not the one returned from get_absolute_url method (example: /admin/r/10/1)

A very old ticket seem to reference the same issue: https://code.djangoproject.com/ticket/7984

Change History (4)

comment:1 by George Tantiras, 8 years ago

Summary: vIew_on_site is not working with inline modelsview_on_site is not working with inline models

comment:2 by George Tantiras, 8 years ago

Description: modified (diff)
Summary: view_on_site is not working with inline modelsview_on_site does not receive the get_absolute_url returning uri

comment:3 by George Tantiras, 8 years ago

Description: modified (diff)

comment:4 by George Tantiras, 8 years ago

Description: modified (diff)
Summary: view_on_site does not receive the get_absolute_url returning uriThe link of the "view_on_site" button is not formed according to the returning result of the "get_absolute_url" method.
Note: See TracTickets for help on using tickets.
Back to Top