property statement first :) thanks again!
class Setting(models.Model):
name = models.CharField(max_length=100)
_value_json = models.TextField()
def _set_json_value(self, value):
self._value_json = json.dumps(value)
def _get_json_value(self):
return json.loads(self._value_json)
value = property(_get_json_value, _set_json_value)
On 27 Okt., 23:40, Patrick <ptrckdn...@googlemail.com> wrote:
> hm .. i thought of that too but i considered it not to be the best
> approach.
> i will try that snippet though.. thank you!
>
> On 27 Okt., 15:49, Shawn Milochik <sh...@milochik.com> wrote:
>
> > Try this instead:
>
> >http://djangosnippets.org/snippets/1478/
>
> > Or you could do it manually in your model:
>
> > 1. Add field _value_json to your model.
> > 2. Add functions (get_value, set_value) which do the simplejson work.
> > 3. Add a property named 'value' with get_value and set_value as its
> > getter and setter.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment