I couldn't find any code for a blog-style "Read more after the jump," so I made a custom filter. It will look for **<!--more-->** for the jump, like in Wordpress.
In **settings.py** set **READ_MORE_TEXT** to what you want the text of the link to be.
`READ_MORE_TEXT = 'Read more after the jump.'`
When you call the filter in your template, pass it the absolute link of that entry. Of course, you have to have your **get_absolute_url** function defined in your model, but you should have that already, right? :P
In this example **entry.body** is the content of the blog entry.
`{% load blog_filters %}`
`{{ entry.body|read_more:entry.get_absolute_url }}`
If anyone has a better way to do this, it is, of course, welcome.
- template
- filter
- blog
- find
- jump
- read
- more
Subclass of the ModelForm which allows to make fields 'display_only'.
This means no formfield will be displayed, but a suitable representation. You can make all fields display_only or just a few (or you can use the form as a normal modelform).
There are also some extra's to easily set attrs on fields or set help_texts on widgets when using this form.
Why ?
I made my own set of generic crud views based on newforms, but added a 'display' view to simply display objects, in the same table layout as the editing is done, but without the fields. I wanted to avoid having to redefine my forms twice and I wanted to reuse some generic templates as much as possible.
Obviously this is not good for performance, but I use it for an intranet app with a lot of objects, but not that big a load.
Their is definitely still a lot of room for improvement, and maybe all this could have been done much easier.
How to use?
See the docstring.
This simple middleware replaces all 'a href' links to the current page to the 'span' elements. This very usefule from the usability point of view.
For example, user open in bowser page http://svetlyak.ru/blog/, and this middleware will replace all 'a' elements on this page, which refer to the '/blog/'. Because of this, link 'Blog' in the main menu, become a simple 'span'.
Next, when user goes to the next page, a post with full comments list ('/blog/123/'), for example, the item 'Blog' in the main menu become a link again!
To use this middleware, just add it to the list of middleware classes:
MIDDLEWARE_CLASSES = ('utils.middleware.RemoveSelfLinks',)
- middleware
- html
- output
- usability
- utils
This view decorator renders automaticaly the template with the context provided both by the view "return" statement. For example:
@auto_render
def my_view(request):
...
return 'base.html', locals()
You can still return HttpResponse and HttpResponseRedirect objects without any problems. If you use Ajax requests, this decorator is even more useful. Imagine this layout:
def aggregating_view(request):
...
context = locals()
partial1 = partial_view_1(request, only_context=True)
partial2 = partial_view_2(request, only_context=True)
# aggregate template include partial templates
return 'aggregate.htmt', context.update(partial1).update(partial2)
def partial_view_1(request):
...
return 'partial_1.html', locals()
def partial_view_2(request):
...
return 'partial_2.html', locals()
This way you can render you view individualy for specific ajax calls and also get their context for the aggregating view.
- render_to_response
- ajax
- decorator
- rendering