Opened 10 years ago

Closed 10 years ago

#24582 closed Uncategorized (worksforme)

ModelAdmin.delete_view(). List of items on level 3 not converted to html list

Reported by: Никита Шультайс Owned by: nobody
Component: contrib.admin Version: 1.8
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

I have 3 Models

  1. Category
  2. Product with FK on Category
  3. Video with FK on Product

When I delete a Category I see
http://shultais.ru/media/temp/django18.jpeg

List of items on level 3 is not converted to html (ul, ol) list and escaped.

Attachments (1)

admin-delete-category.png (20.3 KB ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Tim Graham, 10 years ago

Could you please share your models? I couldn't reproduce this from the relationships you described. Here is what I tried:

class Category(models.Model):
    name = models.CharField(max_length=100)

class Product(models.Model):
    name = models.CharField(max_length=100)
    category = models.ForeignKey(Category)

class Video(models.Model):
    product = models.ForeignKey(Product)

class Order(models.Model):
    product = models.ForeignKey(Product)

comment:2 by Никита Шультайс, 10 years ago

My models

# -*- coding: utf-8 -*-
import uuid

from django.db import models
from django.contrib.postgres.fields import ArrayField, HStoreField, IntegerRangeField
from django.contrib.auth.models import User


class Category(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        verbose_name = u"category"
        verbose_name_plural = u"categories"
        ordering = ("name",)

    def __unicode__(self):
        return self.name


class Product(models.Model):
    active = models.BooleanField(default=True)
    category = models.ForeignKey(
        Category,
        default=None,
        null=True,
        verbose_name=u"category",
    )
    name = models.CharField(max_length=100)
    price = models.DecimalField(decimal_places=0, max_digits=10, blank=True, default=0)
    quantity = models.IntegerField(default=0)

    # Для Postgresql
    sizes = ArrayField(
        base_field=models.IntegerField(),
        size=8,
        verbose_name=u"Sizes",
        blank=True,
        null=True,
        default=None
    )
    sizes_full = HStoreField(
        u"Sizes and quantity",
        blank=True,
        null=True,
        default=None
    )
    age = IntegerRangeField(blank=True, null=True, default=None)

    class Meta:
        verbose_name = u"product"
        verbose_name_plural = u"products"

    def __unicode__(self):
        return self.name

COLORS = [
    ["", u"---"],
    ["black", u"black"],
    ["white", u"white"],
    ["red", u"red"],
    ["blue", u"blue"],
    ["green", u"green"],
    ["yellow", u"yellow"],
]


class ProductVideo(models.Model):
    product = models.ForeignKey(Product)
    duration = models.DurationField()
    code = models.TextField(u"YouTube code")

    class Meta:
        verbose_name = u"video"
        verbose_name_plural = u"video"

    def __unicode__(self):
        return u"video %s" % self.id


class Color(models.Model):
    product = models.ForeignKey(Product)
    color = models.CharField(max_length=10, default="", choices=COLORS)
    quantity = models.IntegerField(default=0)

    class Meta:
        verbose_name = u"color"
        verbose_name_plural = u"colors"
        unique_together = ("product", "color")

    def __unicode__(self):
        return u"%s: %s" % (self.product.name, self.get_color_display())


class Order(models.Model):
    user = models.ForeignKey(User, verbose_name=u"user")
    id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)
    product = models.ForeignKey(Product)
    quantity = models.IntegerField(default=1)

    class Meta:
        verbose_name = u"order"
        verbose_name_plural = u"orders"

    def __unicode__(self):
        return u"Order %s" % self.id

comment:3 by Tim Graham, 10 years ago

I couldn't reproduce your screenshot. Attaching a screenshot of what I see.

by Tim Graham, 10 years ago

Attachment: admin-delete-category.png added

comment:4 by Tim Graham, 10 years ago

Resolution: worksforme
Status: newclosed

Please reopen if you can provide more detailed steps, thanks!

Note: See TracTickets for help on using tickets.
Back to Top