#22413: Allow model instance attributes in ModelAdmin.fields
-------------------------+-------------------------------------------------
     Reporter:  moritzs  |      Owner:  nobody
         Type:  New      |     Status:  new
  feature                |    Version:  master
    Component:           |   Keywords:  ModelAdmin instance attribute field
  contrib.admin          |  Has patch:  0
     Severity:  Normal   |      UI/UX:  0
 Triage Stage:           |
  Unreviewed             |
Easy pickings:  0        |
-------------------------+-------------------------------------------------
 Say your model uses `__getattr__` like that:

 {{{
 class MyModel(models.Model):
     value = models.CharField(max_length=20)

     def __getattr__(self, name):
         if name == 'reversed_value':
             return self.value[::-1]
         else:
             raise AttributeError()
 }}}
 Then you can't use the attribute `reversed_value` in `ModelAdmin.fields`
 because the attribute is only defined in a model '''instance''' but not in
 the class itself.
 I suggest adding a field `model_instance_fields` in `ModelAdmin` that
 contains the names of all fields that will be only defined in model
 instances.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22413>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.0a46d21fdb7e2539c46982d5397e8772%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to