#7984 closed Uncategorized (fixed)
Admin "View on site" builds wrong URL with inline models
Reported by: | Philipp Wollermann | Owned by: | Brian Rosner |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Attachments (1)
Change History (11)
comment:1 by , 16 years ago
milestone: | → 1.0 beta |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 16 years ago
Attachment: | admin-inlineviewonsite.diff added |
---|
comment:2 by , 16 years ago
Has patch: | set |
---|
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 16 years ago
milestone: | 1.0 beta → 1.0 |
---|
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 8 years ago
Easy pickings: | unset |
---|---|
Severity: | → Normal |
Type: | → Uncategorized |
UI/UX: | unset |
Using Django-1.10 under Python-3.4.2, although view_on_site
works great for the
admin.ModelAdmin
, inlines (
admin.StackedInline
) do not seem to use the model's
get_absolute_url
and return a completely wrong url which contains a localized id (
/admin/<model>/r//1.234
).
comment:8 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
comment:9 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Please do not reopen such old bug reports, just create a new one and reference this issue in the description.
I can confirm that. Looks like a bug.