﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7984	"Admin ""View on site"" builds wrong URL with inline models"	Philipp Wollermann	Brian Rosner	"I've got a model ""Product"" and a model ""Flavor"": (stripped-down versions)

{{{
class Product(models.Model):
	name = models.CharField(verbose_name=_(""Name""), max_length=100, unique=True)
	slug = models.SlugField(editable=False, blank=True)

	@permalink
	def get_absolute_url(self):
		return (""example.shop.views.view_product"", (), {""slug"": self.slug, ""product"": self.id})

	def save(self):
		self.slug = slugify(self.name)
		super(Product, self).save()

	def __unicode__(self):
		return u""%s"" % (self.name,)

class Flavor(models.Model):
	product = models.ForeignKey(Product, verbose_name=_(""Product""))
	name = models.CharField(verbose_name=_(""Name""), max_length=100)
	slug = models.SlugField(editable=False, blank=True)

	@permalink
	def get_absolute_url(self):
		return (""example.shop.views.view_flavor"", (), {""product_slug"": self.product.slug, ""flavor_slug"": self.slug, ""flavor"": self.id, ""product"": self.product.id})

	def save(self):
		self.slug = slugify(self.name)
		super(Flavor, self).save()

	def __unicode__(self):
		return u""%s (%s)"" % (self.product, self.name)
}}}

Now I look at them in admin and want to use the ""View on site"" button. Admin builds the following URLs:

Example product: http://example.com/admin/r/12/2/

Example flavor: http://example.com/admin/r/13/3/

Now I change my admin.py, so that Flavor is inline-edited in Product:
{{{
class FlavorInline(admin.TabularInline):
	model = Flavor

class ProductAdmin(admin.ModelAdmin):
	list_display = (""id"", ""name"")
	inlines = [FlavorInline,]
}}}

Now admin builds the following URLs for ""View on site"":

Example product: http://example.com/admin/r/12/2/

Example inlined flavor: http://example.com/r//3/

Seems like the first parameter is not computed correctly on inlined-models!

Best regards,
Philipp
"	Uncategorized	closed	contrib.admin	dev	Normal	fixed			Accepted	1	0	0	0	0	0
