Changes between Initial Version and Version 2 of Ticket #27757


Ignore:
Timestamp:
Jan 22, 2017, 4:44:31 AM (8 years ago)
Author:
George Tantiras
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27757

    • Property Summary vIew_on_site is not working with inline modelsview_on_site does not receive the get_absolute_url returning uri
  • Ticket #27757 – Description

    initial v2  
    11I am using Django-1.10 under Python-3.4.2.
    22
    3 Although ```view_on_site = True``` works great for the ```admin.ModelAdmin``` using the url provided by the ```get_absolute_url``` method of the model, inlines of the same model (```admin.StackedInline``` view) return a completely wrong url which points to the admin and contains a localized id (```/admin/<model>/r//1.234```).
     3{{{
     4from django.db import models
    45
    5 Even if ```def view_on_site(self.obj)``` method is defined in the ```admin.StackedInline``` view, the result is ignored and the same localized url (```/admin/<model>/r//1.234```) is returned.
    66
     7class Product(models.Model):
     8    name = models.CharField(verbose_name="Name", max_length=100, unique=True)
     9
     10    def get_absolute_url(self):
     11        return "test-string/{0}".format(self.id)
     12
     13
     14class Flavor(models.Model):
     15    product = models.ForeignKey(Product, verbose_name="Product")
     16    name = models.CharField(verbose_name="Name", max_length=100)
     17
     18
     19    def get_absolute_url(self):
     20        return "test-string-2/{0}".format(self.id)
     21}}}
     22
     23
     24admin.py:
     25{{{
     26from django.contrib import admin
     27from inline_online.models import Flavor, Product
     28
     29
     30class FlavorInline(admin.TabularInline):
     31    model = Flavor
     32
     33
     34class ProductAdmin(admin.ModelAdmin):
     35    list_display = ("id", "name")
     36    inlines = [FlavorInline, ]
     37
     38
     39admin.site.register(Product, ProductAdmin)
     40
     41
     42class FlavorAdmin(admin.ModelAdmin):
     43    view_on_site = True
     44
     45
     46admin.site.register(Flavor, FlavorAdmin)
     47}}}
     48
     49The `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`)
    750A very old ticket seem to reference the same issue: https://code.djangoproject.com/ticket/7984
Back to Top