#3148: Add getters and setters to model fields
-----------------------------+----------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: telenieko
Status: assigned | Component: Database wrapper
Version: SVN | Resolution:
Keywords: MESSAGE | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------+----------------------------------------------
Changes (by telenieko):
* owner: nobody => telenieko
* status: new => assigned
* version: => SVN
* summary: [patch] Add getters and setters to model fields => Add
getters and setters to model fields
Comment:
Hi there,
I found that ticket looking for a way to achieve exactly what this ticket
asks for and saw adrian's comment above about trying to use normal
properties to improve the patch.
I've just attached a new patch with tests and docs that does just this. In
essence you'd do:
{{{
#!python
from django.db import models
class Person(models.Model):
def _get_name(self):
return self.__name
def _set_name(self, value):
self.__name = value
name = models.CharField(max_length=30, property=(_get_name,
_set_name))
}}}
And django will create "Person.name" as a property() using the tuple
given.
--
Ticket URL: <http://code.djangoproject.com/ticket/3148#comment:8>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---