Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a generic JSONField to Publishable to store project-specific metadata #57

Closed
honzakral opened this issue Jan 29, 2012 · 5 comments
Closed

Comments

@honzakral
Copy link
Member

Almost every application I have seen on ella has some need for added flexibility. I propose we add an optional JSONField to Publishable that individual plug-ins and projects can use to store their specific stuff. Some examples:

  • store comment count with publishable
  • tag lists
  • importance
  • source information (commercial, licence)
  • template used to render
  • ....

I also believe some conventions (a two line note in help_text fo the fields sounds enough) should be in place to provide namespaces (for example store your stuff under "app_name", for example:

{
'comments': {'count': 12, 'latest': '20120128'},
'tagging': {'public_tags': ['summer'], 'editorial_tags': ['white bikiny']}
}

@xaralis
Copy link
Member

xaralis commented Jan 29, 2012

Yep, that sounds nice. We might create some accessors for the field that handle the namespaces for us... Like:

>>> p = Publishable.objects.get(pk=1)
>>> p.get_meta('tagging', 'public_tags')
>>> ['summer']
>>> p.set_meta('tagging', 'editorial_tags', ['white bikiny'])
>>> p.save()
>>> p.get_meta('tagging')
>>> {'public_tags': ['summer'], 'editorial_tags': ['white bikiny']}

@xaralis
Copy link
Member

xaralis commented Jan 30, 2012

This looks like an simple yet functional JSONField implementation we can use:

https://github.com/bradjasper/django-jsonfield

@martinbilek
Copy link
Member

JSONField sounds good to me. Also other models should use JSONField, for example category to store informations like "meta-description", "browser-title", "link-title"...

@ghost ghost assigned honzakral Jan 30, 2012
@honzakral
Copy link
Member Author

OK, I will take care of this today, at least now I would like to avoid constructing a special interface for this - I learned the hard way (by deleting 20k+ LOC from ella that were mostly mine/my decision) that the simplest way is the best by far ;)

let's see how useful it is with just the field and add the methods later only if we find we absolutely need them.

@xaralis
Copy link
Member

xaralis commented Jan 30, 2012

Please, add JSONField to category model too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants