#29331: Model fields where the field name is shadowed by Python property aren't
     Reporter:  Ben Mathes           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  models,              |             Triage Stage:  Accepted
  deferred_field, save               |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0

Comment (by Simon Charette):

 FWIW adjusting your descriptor to use `__dict__['field']` instead of
 `__dict__['_field']` should work just fine.

 class SomeModel(models.Model):
     a contrived model field where we want a "field" that is stored
     in a "field" column, but we use @property getter/setters so
     we name the SomeModel class's attribute as "_field".
     name = models.TextField(null=True)
     _field = models.TextField(name="field")

     def field(self):
         return self.__dict__['field'].upper()

     def field(self, new_value):
         self.__dict__['field'] = new_value.lower()

 I don't think we can change the assumption that `name` either set
 implicitly or explicitly through a parameter  the will be present in
 `__dict__` without breaking a lot of stuff.

Ticket URL: <https://code.djangoproject.com/ticket/29331#comment:7>
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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to