On Fri, Aug 31, 2012 at 10:53 PM, RK <romainknezevic@gmail.com> wrote:
> I'd like to have the content of one <p> tag in the homepage editable in
> admin back-office, going through a whole model feels like an overkill, what
> alternatives do I have ?
>
> If there's no alternative, is there a way to properly limit the number of
> elements to 1 in the admin panel ?
>
> Any help appreciated, I'm sure I missed something obvious because it seems
> like a basic need. (I'm new to django if u didn't catch it !)
Think of it this way -- you have a piece of data that you want to be
persistent. You need to persist it somewhere. If you're going to
persist it to the database, you need to put it in a table.
Django doesn't have a built in "table for singleton values". However,
such an app that implemented such a feature wouldn't be hard to write
(after all, it's just a table of key-value pairs). Is it a waste?
Maybe. But the overhead of a single table isn't huge, so it isn't a
*big* waste. You'd have to balance your need to have the feature
against the extra few kB of disk space you'll be using.
Thinking of all the weird ways you could abuse the pieces that are
already in the box -- Django has a database-backed cache backend,
which is effectively just a table that contains key-value pairs. Store
your value with no expiry date, and you've got persistent storage
without explicitly creating a "values for my homepage" table. However,
you won't get a nifty admin interface for free; the cache tables
aren't exposed through the admin interface. However, you could write a
custom admin UI page and hook it in.
Then, you have non-database options -- for example, Redis is a
persistent key-value store; again, with a custom view plugged into the
admin, you could persist configuration values.
I hope that gets some ideas bubbling in your mind :-)
Yours,
Russ Magee %-)
--
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment