Login

Snippets by youell

Snippet List

SnippySnip

** Help me get better! If you vote (either way) please leave a comment if you have time and say what was good or bad. I appreciate any and all feedback. Thanks! ** I keep finding places in my apps where I need an isolated snippet of text that can periodically be changed from the admin interface. Most often it's html but sometimes it's text, javascript, or css. Use it like so: (Assuming this snippet lives in snippy_snip/models.py and there is a snippet named "Welcome Message" in the database) from snippy_snip.models import snip msg = snip("Welcome Message") Or, you might populate a parameter hash for a template: def showpage(request): params = { 'welcome': snip('Welcome Message'), 'video1': snip('Video 1'), 'NavHeader': snip('Nav.SectionHeader'), } return render_to_response("main.html", params) For clarity, *params* might look something like this: welcome -> "Welcome to our site. Please use the menu on the left..." video1 - > a YouTube snippet NavHeader -> Some HTML which comprises the top of a navigation menu. This is a very simple bit of code but I've found it very useful. It isn't intended for instant changes... Your snippets will cache like anything else, which may cause confusion if you expect immediate changes. And it's probably not great for a high traffic site, but for my moderate traffic sites and workgroup apps I've found it useful. (This code was created for 0.96, but I'm working to bring it into alignment with the latest svn version of Django, see comments.)

  • text
  • javascript
  • html
  • snippet
Read More

youell has posted 1 snippet.