I would like to escape the data from a model attribute...

Here a example:



Old model:
-------------------------------------------------------------
class Page(models.Model):
     ...
     name = models.CharField()
     ...
-------------------------------------------------------------


I have changed the model to this:
-------------------------------------------------------------
class Page(models.Model):
     ...
     __name = models.CharField(
         db_column='name'
     )
     def __get_name(self):
         return escape(self.__name)

     def __set_name(self, data):
         self.__name = data

     name = property(__get_name, __set_name)
     ...
-------------------------------------------------------------



Now, i have a problem :(

This works, fine:
        page = Page.objects.all()[0]
        print page.name


But here i get a 'FieldDoesNotExist' Traceback:
        print Page.objects.values("name")



The complete traceback:
-------------------------------------------------------------
Traceback (most recent call last):
   File "./PyLucid_shortcuts_test.py", line 24, in <module>
     print Page.objects.values("name")
   File "./django/db/models/query.py", line 108, in __repr__
     return repr(self._get_data())
   File "./django/db/models/query.py", line 482, in _get_data
     self._result_cache = list(self.iterator())
   File "./django/db/models/query.py", line 597, in iterator
     fields = [self.model._meta.get_field(f, many_to_many=False) for f in 
self._fields]
   File "./django/db/models/options.py", line 131, in get_field
     raise FieldDoesNotExist, '%s has no field named %r' % (self.object_name, 
name)
django.db.models.fields.FieldDoesNotExist: Page has no field named 'name'
-------------------------------------------------------------


Why?
Is this a bug?



-- 
Mfg.

Jens Diemer


----
A django powered CMS: http://www.pylucid.org


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to