I hereby claim:
- I am petersanchez on github.
- I am petersanchez (https://keybase.io/petersanchez) on keybase.
- I have a public key whose fingerprint is 9095 6225 167A 28F5 A0B4 61A2 838F FCD2 3122 35D1
To claim this, I am signing this object:
from .mixins import SearchResultsAdminMixin | |
class BlogPostAdmin(SearchResultsAdminMixin, admin.ModelAdmin): | |
search_fields = ['title', 'slug', 'body'] |
from django.db.models import Q, Case, When, Value, IntegerField | |
class SearchResultsAdminMixin(object): | |
def get_search_results(self, request, queryset, search_term): | |
''' Show exact match for title and slug at top of admin search results. | |
''' | |
qs, use_distinct = \ | |
super(SearchResultsAdminMixin, self).get_search_results( | |
request, queryset, search_term) |
class BlogPostAdmin(admin.ModelAdmin): | |
search_fields = ['title', 'slug', 'body'] |
class BlogPost(models.Model): | |
title = models.CharField(max_length=200) | |
slug = models.SlugField(max_length=200) | |
body = models.TextField() |
I hereby claim:
To claim this, I am signing this object:
from django.db import models | |
from django.db.models.signals import post_init | |
# Generic models... | |
class Note(models.Model): | |
note = models.TextField() | |
class TimeLog(models.Model): |