Is there a way to make custom model field that works normally except
for database interaction where it is ignored. In looking at the
source it doesn't seem possible but I thought it couldn't hurt to ask.
I have a serialized model field, based on a text field. I usually use
it to store random bits of data in a python dict that may vary from
model to model, or for playing around where I don't want to deal with
changing the database schema.
What I've done is also create a descriptor class that allows me to
access keys in the serialized field as if they were model
properties.
class SomeModel(models.Model):
extra = cJSONField()
prefs=DynField('_prefs','extra')
logos=DynField('_logos','extra')
allowed=DynField('_allowed','extra')
here extra is just the serialized field, and prefs,logs, and allowed
are fake fields that get/set data from the serialized field according
to their assigned keys. So I've basically got something like
extra = {'_prefs': value1, '_logos',value2, '_allowed': value3}
that is serialized and stored in the database.
Everything works fine, except I'd really like to have those fields
available in the Admin app, which they would be if I could disguise
them a bit and stick em in with the real model fields so the Admin
could recognize them.
In case my example wasn't clear, here is the code.
http://dpaste.com/26157/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---