On Jul 4, 9:27 am, Damon Timm <[email protected]> wrote:
> Hello everyone -
>
> I wondered if anyone had insight on a Model for site-wide "global"
> options.  I am thinking of a place to store: site title, site meta,
> site description, specific global links (twitter, facebook, etc),
> support contact email, etc ... The model itself doesn't seem too
> complicated, maybe:
>
> class GlobalOptions(models.Model):
>     opiton = models.SlugField('Machine Readable Option
> Name',max_length=50,unique=True)
>     value = models.TextField('Option Value')
>     # more fields could be included, of course (date_created, description, 
> blah)
>
> My question, though, is about how to easily get these new "options"
> into a template tag.  So that I could simply do:
>
> {{ globaloptions.optionname }}
>
> And it would return the value for that option or, if the option didn't
> exist, it would return nothing.  I have been looking around for a way
> to do this and coming up blank -- I am new to both Python and Django,
> so I'm sure the answer is there, I just don't know where/how to look
> for it.
>
> Any insight would be great!
>
> Damon

You can set a globaloptions dictionary in the response context with
option attribute as key and value attribute as value.

[]s
daniel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to