from datetime import datetime
from django.db import models
from .utils import slugify_with_date_now


class Category(models.Model):
    title = models.CharField(max_length=255)
    slug = models.CharField(max_length=255)

    @classmethod
    def all(cls):
        return cls.objects.all()

    @classmethod
    def create(cls, title):
        now = datetime.now()
        return cls.objects.create(title=title,
                                  slug=slugify_with_date_now(title, now))

    @classmethod
    def find(cls, keyword):
        return cls.objects.filter(title=keyword)


class Book(models.Model):
    title = models.CharField(max_length=255)
    slug = models.CharField(max_length=255)
    category = models.ForeignKey(Category)

    @classmethod
    def all(cls):
        return cls.objects.all()

    @classmethod
    def create(cls, title, category):
        now = datetime.now()
        return cls.objects.create(title=title,
                                  slug=slugify_with_date_now(title, now),
                                  category=category)

    @classmethod
    def find(cls, keyword):
        return cls.objects.filter(title=keyword)


class Compass(object):
    @classmethod
    def find(cls, **kwargs):
        title = kwargs.get('title')
        category = kwargs.get('category')
        if not title and not category:
            return Book.all()
        if not title:
            return Book.find(category=Category.find(title=category))
        if not category:
            return Book.find(title=title)

    @classmethod
    def heading(cls, **kwargs):
        title = kwargs.get('title')
        category = kwargs.get('category')
        if not title and not category:
            return "All books"
        if not title:
            return "All book titles under {}".format(category)
        if not category:
            return "All book titles like {}".format(title)

@@ -507,39 +507,37 @@
   def find(cls, 
-keyword
+title
 ):%0A        retur
@@ -555,39 +555,101 @@
 ts.filter(title=
-keyword
+title)%0A%0A    def __str__(self):%0A        return %22%7B%7D%22.format(self.title,
 )%0A%0A%0Aclass Book(m
@@ -916,16 +916,17 @@
 category
+,
 ):%0A     
@@ -1163,17 +1163,216 @@
 ls, 
-keyword):
+title=None, category=None,):%0A        if title and not category:%0A            return cls.objects.filter(title=title,)%0A        if category and not title:%0A            return cls.objects.filter(category=category,)
 %0A   
@@ -1412,15 +1412,32 @@
 tle=
-keyword
+title, category=category
 )%0A%0A%0A
@@ -2110,32 +2110,32 @@
 f not category:%0A
-
             retu
@@ -2173,12 +2173,80 @@
 rmat(title)%0A
+        return %22All books like %7B%7D under %7B%7D%22.format(title, category)%0A

Correct arg names and return title when title and category is specified