Opened 3 years ago

Last modified 3 years ago

#32467 closed Cleanup/optimization

django admin widget.attrs not work with ForeignKey — at Version 3

Reported by: Hassan Igbaria Owned by: Hassan Igbaria
Component: Forms Version: 3.1
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 Hassan Igbaria)

self.fields['parent'].widget.attrs = {'class': 'custom-class'}

parent is ForeignKey field

class Category(models.Model):
    title = models.CharField(_('Title'), max_length=300)
    description = models.TextField(_('Description'), null=True, blank=True)
    is_active = models.BooleanField(_('Active ?'), default=True)
    image = models.ImageField(
        _('Image'), upload_to="category/", null=True, blank=True
        )
    parent = models.ForeignKey(
        "self", verbose_name=_('Parent'), on_delete=models.SET_NULL,
        null=True, blank=True
        )

Change History (3)

comment:1 by Hassan Igbaria, 3 years ago

Description: modified (diff)

comment:2 by Hassan Igbaria, 3 years ago

Description: modified (diff)
Owner: changed from nobody to Hassan Igbaria
Status: newassigned

comment:3 by Hassan Igbaria, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top