Coder Social home page Coder Social logo

clintecker / django-chunks Goto Github PK

View Code? Open in Web Editor NEW
301.0 301.0 100.0 160 KB

Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface.

Home Page: http://github.com/clintecker/django-chunks

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-chunks's Introduction

Welcome to my Github! ๐Ÿ˜Ž

django-chunks's People

Contributors

clintecker avatar firass avatar igorsobreira avatar thefekete avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-chunks's Issues

upload your package to PYPI

Please, we're using chunks in many projects, and it would be great if we can download it with setuptools.
Thanks!

cache key can be invalid

The Chunk key field is a CharField, which can take almost any kind of character data, including Unicode, spaces, whatever.

In the templatetag, the chunk key is used as part of the cache key. If using memcached with python-memcached, even spaces are illegal in a cache key. This causes 500 errors.

My first solution was to slugify the chunk key before using it as cache key. This works, but raises the possibility of two overly-similar (but still unique) chunk keys slugifying to the same cache key and stomping over each other's cache. The only way this would really work is if chunks gained an actual SlugField with uniqueness enforced.

So my second solution (found in my fork) was to rip out the direct caching support entirely. IMO there's no reason for django-chunks to have its own (buggy) cache support, when its just as easy (and more flexible) to wrap calls to the chunk tag with Django's built-in template fragment caching tags.

If {{ chunk name }} then do something?

Anyone know if this is possible? I've messed around a bit and can't seem to get anything to work so I assume it won't work but was curious if anyone has done something like this?

{% if chunk_name %}
do something
{% endif %}

Chunks are cached forever by default

If you don't pass a cache timeout to {% chunk %}, the chunk contents will be cached forever (or until the cache runs out of space). I can't see how this would ever be desirable behavior. The chunk is being stored in the database so it can be modified at will, yet the default behavior prevents that from taking effect. I'd recommend merging in carljm/django-chunks@8dcf287e to rip out the caching support altogether. Users who want to cache the chunk can wrap it in {% cache %}.

Alternatively, the Chunk model should clear the cached value on save.

Allow chunk content to included (like the {% include %} tag)

It would be nice to be able to include a chunk in a similar fashion to the way the {% include %} tag works. I've created a patch that adds an additional tag to django-chunks, {% include_chunk %}, which can be use like so:

{% include_chunk "some_chunk_name" %}

The diff can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.