I think the correct syntax is: cls._meta.add_virtual_field(self)
The problem is that if I use this syntax it seems that the admin ignores these fields, what happens is that the changes I make to the virtual fields are ignored. These are the test results related to the VirtualField implementation: Creating test database for alias 'default'... .FFF..E.......E.F.....F...... ====================================================================== ERROR: test_create (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1427, in test_create text='create3' File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/models/query.py", line 370, in create obj = self.model(**kwargs) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/models/base.py", line 452, in __init__ raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0]) TypeError: 'boolean_true' is an invalid keyword argument for this function ====================================================================== ERROR: test_migrations (django_hstore_tests.tests.SchemaTests) failing test for https://github.com/djangonauts/django-hstore/issues/103 ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1565, in test_migrations call_command('migrate', 'django_hstore_tests') File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 115, in call_command return klass.execute(*args, **defaults) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle executor.migrate(targets, plan, fake=options.get("fake", False)) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate self.apply_migration(migration, fake=fake) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration migration.apply(project_state, schema_editor) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply operation.database_forwards(self.app_label, schema_editor, project_state, new_state) File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 127, in database_forwards from_field = from_model._meta.get_field_by_name(self.name)[0] File "/home/nemesis/.virtualenvs/django-hstore/local/lib/python2.7/site-packages/django/db/models/options.py", line 420, in get_field_by_name % (self.object_name, name)) FieldDoesNotExist: SchemaDataBag has no field named u'datetime' ====================================================================== FAIL: test_admin_add (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1305, in test_admin_add self.assertEqual(d.number, 3) AssertionError: 0 != 3 ====================================================================== FAIL: test_admin_add_utf8 (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1317, in test_admin_add_utf8 self.assertEqual(d.number, 3) AssertionError: 0 != 3 ====================================================================== FAIL: test_admin_change (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1334, in test_admin_change self.assertEqual(d.number, 6) AssertionError: 1 != 6 ====================================================================== FAIL: test_reload_schema (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1472, in test_reload_schema self.assertEqual(len(SchemaDataBag._meta.fields), len(original_schema) + concrete_fields_length) AssertionError: 3 != 17 ====================================================================== FAIL: test_schemadatabag_validation_error (django_hstore_tests.tests.SchemaTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/www/django-hstore/tests/django_hstore_tests/tests.py", line 1277, in test_schemadatabag_validation_error d.full_clean() AssertionError: ValidationError not raised ---------------------------------------------------------------------- Ran 29 tests in 1.749s FAILED (failures=5, errors=2) Federico -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6e29cefd-eaaa-49e3-8c2e-c47887eb3ae2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.