#32467: django admin widget.attrs not work with ForeignKey
-------------------------------------+-------------------------------------
     Reporter:  Hassan Igbaria       |                    Owner:  Hassan
         Type:                       |  Igbaria
  Cleanup/optimization               |                   Status:  assigned
    Component:  Forms                |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hassan Igbaria):

 * owner:  nobody => Hassan Igbaria
 * status:  new => assigned


Old description:

> 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
>         )
>
> }}}

New description:

 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
         )

 }}}

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32467#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.7f588c2be557a776f7523483912743d8%40djangoproject.com.

Reply via email to