This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import get_object_or_404, render_to_response | |
from django.template import RequestContext | |
from myapp.models import Note | |
def note_detail(request, slug): | |
note = get_object_or_404(Note, slug=slug) | |
editable = request.user.is_authenticated and request.user.id == note.author.id | |
return render_to_response('myapp/note_detail.html', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
from django.db.models import Q | |
from django.shortcuts import _get_queryset | |
def search(klass, search_fields, search_string): | |
""" | |
Perform a quick and dirty model "search", similar to how the admin's | |
`search_fields` works (see http://tinyurl.com/66xz2n):: |